Hacker News new | ask | show | jobs
by arp242 799 days ago
I like using subshells for this:

  (
      cd dir
      for f in ./*; [..]
  )
There's a few scenarios where this won't work (mainly if you want to set a variable from the "outer scope"), but 99% of the time it works nicely.
1 comments

Ah, that's a nice/neat thought - thank you for sharing! Makes total sense, temporary/disposable shell for such things