-
Notifications
You must be signed in to change notification settings - Fork 0
Shell script
Kenichi Kamiya edited this page Jan 30, 2025
·
9 revisions
Aside from 🤮, I need to write Shell script in several place.
This is a note for me.
-
-e
: exists -
-f
: exists & regular # "regular" means both text and binary. In other words excluding directory, symlink and device -
-d
: exists & directory -
-r
: exists & the user has read permission -
-w
: exists & the user has write permission -
-x
: exists & executable -
-N
: exists & modified from last read -
-s
: exists & non empty
-
-n
: non empty -
-z
: empty
-
-
: Enable -
+
: Disable -
-e
: exit with non 0 -
-u
: exit with undefined variable -
-x
: print executed command -
-o
: # TODO -
pipefail
: # TODO
> dir="$(mktemp --directory | tee --append /dev/tty)"
/tmp/tmp.y2NaKkqILD
> echo $dir
/tmp/tmp.y2NaKkqILD
- https://stackoverflow.com/a/28090709
- https://github.com/kachick/dotfiles/pull/1063/files#diff-0f761dec41f629bec1988e89fea47b068a4274580b5e4d80baeb47d45007cc54R7
- https://github.com/kachick/dotfiles/blob/beabf65a88671770b85029b71450fabee5c9868b/pkgs/git-log-fzf/git-log-fzf.bash#L28
- https://github.com/kachick/dotfiles/blob/beabf65a88671770b85029b71450fabee5c9868b/pkgs/fzf-bind-posix-shell-history-to-git-commit-message/fzf-bind-posix-shell-history-to-git-commit-message.bash#L9
- https://github.com/kachick/dotfiles/blob/beabf65a88671770b85029b71450fabee5c9868b/pkgs/safe_quote_backtik/safe_quote_backtik.bash#L1-L3