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*

3
  • I suggest adding double quotes around $PWD and $v, in case you have directory names with spaces in them (lamentably common on some systems). Commented Dec 6, 2019 at 1:24
  • It doesn't seem to be necessary with bash in the particular case of an index in array[index]=..., but you are right that in general you should double-quote variables, and there is no harm in doing so in this case. Commented Dec 6, 2019 at 15:32
  • Also, in your pushd() function, the builtin pushd command prints the directory stack. In this case, it will print the stack before it's de-duplicated. Suggested change: pushd() { builtin pushd "$@" >/dev/null ; dedup ; dirs ; } (not tested). Commented Dec 6, 2019 at 18:32