diff options
author | xyz <gky44px1999@gmail.com> | 2021-09-29 16:01:07 -0700 |
---|---|---|
committer | xyz <gky44px1999@gmail.com> | 2021-09-29 16:01:07 -0700 |
commit | 1704305c1fece7916db0a2ded51b932f76bf593a (patch) | |
tree | daaf5766aabcc3afeccaca816f7d1091084efcc7 | |
parent | 7744f84db8d73106614c23e00ef21a8dd86a0051 (diff) |
o, add nohup
-rwxr-xr-x | .local/bin/o | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/.local/bin/o b/.local/bin/o index 2e1230fd..9a08cd0b 100755 --- a/.local/bin/o +++ b/.local/bin/o @@ -1,6 +1,19 @@ #!/bin/sh -# I don't care about errors, I don't want to handle errors, just shut up please. -# I don't understand nohup, may be useful in the future +# useful links +# https://stackoverflow.com/questions/3430330/best-way-to-make-a-shell-script-daemon +# https://serverfault.com/questions/117152/do-background-processes-get-a-sighup-when-logging-off # https://wiki.archlinux.org/title/default_applications -xdg-open "$@" 0<&- >&- 2>&- & + +# improve +# if $1 is executable script filename in current dir and no ./ in front, use ./$1 ? +# also consider if $1 is executable but is directory? + +# I don't care about errors, I don't want to handle errors, just shut up please. +# nohup seems not necessary if don't care about daemon SIGHUP requirement + +if [ $# -eq 1 ] && [ -e "$1" ] && ! [ -x "$1" ]; then + nohup xdg-open "$1" 0<&- >&- 2>&- & +else + nohup "$@" 0<&- >&- 2>&- & +fi |