readlinkf icon indicating copy to clipboard operation
readlinkf copied to clipboard

Always run in a subshell

Open jbrubake opened this issue 1 year ago • 1 comments

Instead of requiring the user to run readlinkf_* in a subshell, this allows the natural syntax readlinkf_* "<path>" to be used without changing the calling shell's directory.

Subshell functions are POSIX-compliant:

2.9.5 Function Definition Command ... The format of a function definition command is as follows:

fname ( ) compound-command [io-redirect ...]

2.9.4 Compound Commands ... ( compound-list ) Execute compound-list in a subshell environment... ... { compound-list ; } Execute compound-list in the current process environment...

jbrubake avatar Oct 10 '24 14:10 jbrubake

So the author already answered in pull request https://github.com/ko1nksm/readlinkf/pull/3 that he prioritizes performance over covering broader use cases as he expects the function to be mostly used with command substitution which already spawns a subshell.

9ao9ai9ar avatar Feb 08 '25 12:02 9ao9ai9ar