Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: