Add shelldash Option to Disable -- Appending in Shell Commands
#2335
+9
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request: Add
shelldashOption to Disable--Appending in Shell CommandsSummary
This PR adds a new
shelldashoption to control whether lf appends--to shell command arguments. This fixes compatibility issues with shells like nushell that do not support the--argument separator in the same way as traditional POSIX shells.Problem Description
lf currently unconditionally appends
--to shell command arguments on Unix/Linux systems to prevent arguments from being interpreted as shell options. While this works correctly for POSIX-compliant shells (sh, bash, zsh), it causes errors with nushell.Example Error with Nushell
lfrc configuration:
Error when invoking the command:
The issue is that nushell interprets the
--as a flag (or incorrectly parses it), whereas traditional shells use--as a standard end-of-options marker.Solution
Added a new boolean option
shelldashthat defaults totrue(preserving current behavior for existing users). Users working with nushell or other incompatible shells can now disable the--appending.After Fix - Working Configuration
This configuration now works correctly - it prints "test" and waits for user input.
Changes Made
opts.goshelldash boolfield togOptsstructopts.gogOpts.shelldash = trueininit()eval.goshelldash,noshelldash,shelldash!os.goshellCommand()to conditionally append--based ongOpts.shelldashKey Implementation Detail
Before (
os.go):After (
os.go):Usage
Users can control the behavior in their
lfrc:Backward Compatibility
true, so existing configurations continue to work unchangedTesting Environment
Checklist
--is still appended by default)set shelldashenables--appendingset noshelldashdisables--appendingset shelldash!toggles the behavior