Follow

someone made a blog post claiming that bash scripts which do things like

mydir=$(pwd)
stuff happens
cd $mydir

is "a waste of time" because scripts run in their own shells.

this is not true if you are *sourcing* the script:

$ sh myscript.sh
and
$ chmod +x myscript.sh; ./myscript.sh

behave as the blog post claims.

. ./myscript.sh

will leave you where the cd commands put you. the blog post completely ignores this fact; you should not.

· · Web · 0 · 0 · 4
Sign in to participate in the conversation
Mastodon @ SDF

"I appreciate SDF but it's a general-purpose server and the name doesn't make it obvious that it's about art." - Eugen Rochko