Skip to main content
5 events
when toggle format what by license comment
Sep 1, 2022 at 10:22 comment added Gilles 'SO- stop being evil' @RichieThomas local_options or emulate -L is only useful inside a function. It's pointless if you want to set options for the whole executable script. Its effect is not limited to a sourced script. WRT function definitions, what matters is the options when the function is executed, which might indeed not match the options when the function was defined.
Sep 1, 2022 at 2:24 comment added Richie Thomas Also, separate question RE: tab completion. Let's say I have a tab-complete function which was previously defined inside a file that has been source’ed. This file included the call to register the function via compctl -K _command_name command_name. In this case, I gather that the shell options which are available to the _command_name function aren’t actually evaluated until the function is called from my terminal tab. In other words, it doesn't matter what the shell options were when the script was sourced, only what they were when I hit the tab key. Is that correct?
Aug 31, 2022 at 23:45 comment added Richie Thomas Thanks, emulate -LR zsh seems to solve my immediate issue! For my own edification, is there something special about the combination of putting both the code and the local_options snippet inside a function, which wouldn't happen if I added the local_options snippet to a plain shell script?
Aug 31, 2022 at 22:59 vote accept Richie Thomas
Aug 31, 2022 at 21:25 history answered Gilles 'SO- stop being evil' CC BY-SA 4.0