Skip to main content
12 events
when toggle format what by license comment
Oct 8, 2018 at 6:35 history edited Kusalananda CC BY-SA 4.0
added 200 characters in body
May 19, 2017 at 18:53 comment added Kusalananda @Pysis Something that is not portable may well work on several system, especially if the shell environment is the same, no worries. By "portable" I mean (cd ...) works in all sh-type shells without using any non-POSIX features. On my machine, with ksh93, neither of popd and pushd exists...
May 19, 2017 at 18:50 comment added Pysis @Kusalananda Really? I've had them work for at least several systems.
May 19, 2017 at 18:34 comment added Kusalananda @Pysis Yes, (cd dir && thing) is also much more portable than using pushd and popd.
May 19, 2017 at 14:46 history edited Kusalananda CC BY-SA 3.0
added 96 characters in body
May 19, 2017 at 13:49 comment added Pysis This Q&A seems to speak of my situation, and may be an improvement on using a surrounding pushd and popd (also > /dev/null if you are trying to avoid the output messages as well), while also keeping the context clean!
May 19, 2017 at 11:13 history edited Kusalananda CC BY-SA 3.0
added 6 characters in body; deleted 1 character in body
May 19, 2017 at 8:21 comment added Kusalananda @AnthonyGeoghegan Ah, that's true. I always use { ... } for consistency with longer functions though.
May 19, 2017 at 8:19 comment added Anthony Geoghegan Excellent, comprehensive answer. I just thought I'd mention that the function definition only needs one method of grouping commands and the parentheses for the subshell are enough: cdrun () ( cd "$1" && shift && command "$@" ).
May 19, 2017 at 7:16 history edited Kusalananda CC BY-SA 3.0
added 725 characters in body
May 19, 2017 at 7:06 history edited Kusalananda CC BY-SA 3.0
added 49 characters in body
May 19, 2017 at 6:59 history answered Kusalananda CC BY-SA 3.0