Add shelldash Option to Disable -- Appending in Shell Commands#2335
Add shelldash Option to Disable -- Appending in Shell Commands#2335clappedscant906 wants to merge 1 commit intogokcehan:masterfrom
shelldash Option to Disable -- Appending in Shell Commands#2335Conversation
|
So this is basically aims to fix There has been an attempt to solve this problem, however the PR was never finished I honestly do prefer the approach suggested by @joelim-work in the original issue as it seems more flexible and potentially also useful for other shells. |
|
Hello, @clappedscant906! |
|
A 'shell' is essentially a runner that can execute a command string, possibly with some arguments. For example, with the configuration
Unfortunately the existing design splits the shell configuration into |
|
Also related |
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