dylanaraps / pure-sh-bible

📖 A collection of pure POSIX sh alternatives to external processes.
MIT License
6.45k stars 281 forks source link

Reduce side effects of string functions #21

Closed chambln closed 4 years ago

chambln commented 4 years ago

Some of the string functions have the side effect of changing shell options—in particular enabling shell globbing. For example if you disable shell globbing with set -f and run, say, trim_all " example string ", you will find that shell globbing has been re-enabled without your asking.

This patches some (or all?) of those functions to restore shell options before they end.

I have tested this carefully, but shell can be tricky to work with so it's possible I've made a mistake somewhere.

dylanaraps commented 4 years ago

These functions are merely examples. You'd obviously work them into your codebase to meet its requirements. Thanks for the PR.