Added gitignore entries needed to ignore derived objects generated from full build...
[bash.git] / examples / scripts / nohup.bash
blob37812931f7efefa185559e9a09a5de0033f58702
2 # BASH VERSION OF nohup COMMAND
4 ctype()
6 path=$(builtin type -p $cmd | sed 1q)
7 if [ -n "$path" ]; then
8 echo "$path"
9 return 0
10 else
11 case "$cmd" in
12 */*) [ -x "$cmd ] && { echo "$cmd" ; return 0; } ;;
13 *) case "$(builtin type -t $cmd)" in
14 "") return 1;;
15 *) echo "$cmd" ; return 0;;
16 esac ;;
17 esac
19 return 1
22 trap '' HUP # ignore hangup
23 command=$(ctype "$1")
24 oldmask=$(umask)
25 umask u=rw,og= # default mode for nohup.out
26 exec 0< /dev/null # disconnect input
27 if [ -t 1 ]; then # redirect output if necessary
28 if [ -w . ]; then
29 echo 'Sending output to nohup.out'
30 exec >> nohup.out
31 else echo "Sending output to $HOME/nohup.out"
32 exec >> $HOME/nohup.out
36 umask "$oldmask"
38 # direct unit 2 to a file
39 if [ -t 2 ]; then
40 exec 2>&1
43 # run the command
44 case $command in
45 */*) exec "$@"
47 time) eval "$@"
49 *) "$@"
51 esac