Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • May also be worth noting that in : ${fdir:="${@: -1}"}, the quotes are in the wrong place as the expansion would be subject to split+glob (and even when passed to : constitute the kind of DoS vulnerability described at Security implications of forgetting to quote a variable in bash/POSIX shells Commented Jul 27, 2021 at 17:13
  • In zsh (or fish), you'd rather use $argv[-1]. Also ${@[-1]} in zsh or yash. Commented Jul 27, 2021 at 17:15
  • Then it would be safer to use ${@:$#}. Commented Jul 27, 2021 at 17:52
  • @Pietru, not sure what difference that would make. It also would give $0 if there were no positional parameters Commented Jul 27, 2021 at 18:51
  • I meant that "${@:$#}" as safer option than "${@: -1}", in case one misses the space. Commented Jul 27, 2021 at 19:13