aboutsummaryrefslogblamecommitdiff
path: root/Keywords/shell.ucl
blob: 4993d2fd93845d45c3b534fe95288dfb426d58aa (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                                                                    
 

               

                                      
                                              








                                                    

                                         
   



                                      
                                            









                                           
                       
               


                                              
     
   
# MAINTAINER: portmgr@FreeBSD.org
#
# @shell bin/shell
#
# Handle adding and remove a path to a shell binary into /etc/shells
#

actions: [file]
post-install-lua: <<EOD
  shell_path = pkg.prefixed_path("%@")
  shell = assert(io.open("/etc/shells", "r+"))
  while true do
    line = shell:read()
    if line == nil then break end
    if line == shell_path then
      -- the shell path is already in the shell file
      shell:close()
      return
    end
  end
  assert(shell:write(shell_path .. "\n"))
  assert(shell:close())
EOD
pre-deinstall-lua: <<EOD
  shell_path = pkg.prefixed_path("%@")
  shellsbuf = ""
  shells_path = "/etc/shells"
  shell = assert(io.open(shells_path, "r+"))
  found = false
  while true do
    line = shell:read()
    if line == nil then break end
    if line == shell_path then
      found = true
    else
      shellsbuf = shellsbuf .. line .. "\n"
    end
  end
  assert(shell:close())
  if found then
    shell = assert(io.open(shells_path, "w+"))
    assert(shell:write(shellsbuf))
    assert(shell:close())
  end
EOD