Skip to content

Commit

Permalink
stronger safety guarantee on flag-like files
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebman committed Dec 12, 2024
1 parent a8f9fd0 commit d23f07f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugins/available/jake-implicit-commands.plugin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,11 @@ function file {
( # TODO: `local -` instead of a subshell?
set -o pipefail
if [[ "$#" -eq 0 ]]; then
command file -E * | pager
# A safer form of file -E * using find
# -maxdepth 1 - find only the files under the starting-point
# -printf '%P\0' - customizing a form of -print0 which strips the ./ prefix that -print0 gives
# %P: File's name with the name of the starting-point under which it was found removed.
find . -maxdepth 1 -printf '%P\0' | xargs --null file -E | pager
else
command file -E "$@" | pager
fi
Expand Down

0 comments on commit d23f07f

Please sign in to comment.