# Quoting & Expansion in Nushell Build 0.67.1 of nushell 3f93dc2f1dab82b7a80e20d5f54b08b33ff4563f ## External commands ### Test 1 with Git's echo.exe | Index | Platform | Test | Result | | ----- | -------- | ---------------------- | --------------------------------------------------------------------------------------------------- | | 1 | Windows | ^echo '\*\*/\*.json' | wix/windows-terminal-profile.json | | 2 | Windows | ^echo "\*\*/\*.json" | wix/windows-terminal-profile.json | | 3 | Windows | ^echo \`\*\*/\*.json\` | .vs\ProjectSettings.json .vs\VSWorkspaceState.json .vscode\launch.json and all the other json flies | | 4 | Windows | ^echo \*\*/\*.json | .vs\ProjectSettings.json .vs\VSWorkspaceState.json .vscode\launch.json and all the other json flies | ### Test 2 with Git's echo.exe but with backslash | Index | Platform | Test | Result | | ----- | -------- | ---------------------- | --------------------------------------------------------------------------------------------------- | | 5 | Windows | ^echo '\*\*\\*.json' | \*\*\*.json | | 6 | Windows | ^echo "\*\*\\*.json" | \*\*\*.json | | 7 | Windows | ^echo \`\*\*\\*.json\` | .vs\ProjectSettings.json .vs\VSWorkspaceState.json .vscode\launch.json and all the other json flies | | 8 | Windows | ^echo \*\*\\*.json | .vs\ProjectSettings.json .vs\VSWorkspaceState.json .vscode\launch.json and all the other json flies | ### Test 3 with cmd.exe /c built-in echo forward slash or backward slash made no difference | Index | Platform | Test | Result | | ----- | -------- | ---------------------- | ------------------ | | 9 | Windows | ^echo '\*\*/\*.json' | '\*\*/\*.json' | | 10 | Windows | ^echo "\*\*/\*.json" | \\"\*\*/\*.json\\" | | 11 | Windows | ^echo \`\*\*/\*.json\` | \`\*\*/\*.json\` | | 12 | Windows | ^echo \*\*/\*.json | \*\*/\*.json | ### Test 4 WSL2 Ubuntu's echo ``` > lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.1 LTS Release: 22.04 Codename: jammy > which echo ╭───┬──────┬───────────────┬──────────╮ │ # │ arg │ path │ built-in │ ├───┼──────┼───────────────┼──────────┤ │ 0 │ echo │ /usr/bin/echo │ false │ ├───┼──────┼───────────────┼──────────┤ │ # │ arg │ path │ built-in │ ╰───┴──────┴───────────────┴──────────╯ ``` | Index | Platform | Test | Result | | ----- | -------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 9 | WSL2 | ^echo '\*\*/\*.json' | \*\*/\*.json | | 10 | WSL2 | ^echo "\*\*/\*.json" | \*\*/\*.json | | 11 | WSL2 | ^echo \`\*\*/\*.json\` | .vscode/settings.json crates/nu-command/assets/228_themes.json samples/wasm/package-lock.json samples/wasm/package.json target/.rustc_info.json and all the other json files | | 12 | WSL2 | ^echo \*\*/\*.json | .vscode/settings.json crates/nu-command/assets/228_themes.json samples/wasm/package-lock.json samples/wasm/package.json target/.rustc_info.json and all the other json files | ### Test 5 with MacOS's built in echo | Index | Platform | Test | Result | | ----- | -------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 13 | MacOS | ^echo '\*\*/\*.json' | \*\*/\*.json| | 14 | MacOS | ^echo "\*\*/\*.json" | \*\*/\*.json| | 15 | MacOS | ^echo \`\*\*/\*.json\` | .vscode/settings.json crates/nu-command/assets/228_themes.json samples/wasm/package-lock.json samples/wasm/package.json target/.rustc_info.json and all the other json files | | 16 | MacOS | ^echo \*\*/\*.json | .vscode/settings.json crates/nu-command/assets/228_themes.json samples/wasm/package-lock.json samples/wasm/package.json target/.rustc_info.json and all the other json files | ### Test 6 quote argument with spaces | Index | Platform | Test | Result | | -------- | -------- | -------- | ------------ | | 17 | MacOS | ^echo "--name='xx' --value='yy'" | --name='xx' --value='yy' | | 18 | MacOS | ^echo '--name="xx" --value="yy"' | --name="xx" --value="yy" | | 19 | Windows | ^echo "--name='xx' --value='yy'" | "--name='xx' --value='yy'" (failure)| | 20 | Windows | ^echo '--name="xx" --value="yy"' | '--name="xx" --value="yy"' (failure) | But if the argument is defined as a variable, we don't need to quote them. ```shell= let argument = "--name='xx' --value='yy'" ``` | Index | Platform | Test | Result | | -------- | -------- | -------- | ------------ | | 21 | MacOS | ^echo $argument | --name='xx' --value='yy' | | 22 | Windows | ^echo $argument | --name='xx' --value='yy' | | Index | Platform | Test | Result | | -------- | -------- | -------- | ------------ | | 23 | MacOS | ^echo '--aa="bbbb"' | --aa="bbbb" | | 24 | MacOS | ^echo "--aa='bbbb'" | --aa='bbbb' | | 25 | MacOS | ^echo --aa="bbbb" | --aa="bbbb" | | 26 | Windows | ^echo '--aa="bbbb"' | --aa=\bbbb" (failure) | | 27 | Windows | ^echo "--aa='bbbb'" | --aa=bbbb (failure) | | 28 | Windows | ^echo --aa="bbbb" | --aa=bbbb (failure) | ### Test 7 - fzf with list of parameters #### Setup ```shell= let-env FZF_DEFAULT_OPTS = '--cycle --layout=reverse --border --height=90% --preview-window=wrap --marker="*"' let log_fmt_str = '%C(bold blue)%h%C(reset) - %C(cyan)%ad%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)' ``` #### Test 7.1 (preview with git show) ```shell= let selected_log_lines = ( git log [--format=format:($log_fmt_str) --date=short --color=always] | fzf [--ansi --multi --tiebreak=index --preview='git show --color=always --stat --patch {1}'] ) ``` #### Result 7.1 - Windows - Fails - MacOs - Fails #### Test 7.2 (preview with git show - change quoting) ```shell= let selected_log_lines = ( git log [--format=format:($log_fmt_str) --date=short --color=always] | fzf [--ansi --multi --tiebreak=index "--preview=git show --color=always --stat --patch {1}"] ) ``` #### Result 7.2 - Windows - Succeeds - MacOs - Succeeds #### Test 7.3 (preview with git show - remove list syntax) ```shell= let selected_log_lines = ( git log [--format=format:($log_fmt_str) --date=short --color=always] | fzf --ansi --multi --tiebreak=index --preview='git show --color=always --stat --patch {1}' ) ``` #### Result 7.3 - Windows - Succeeds - MacOs - Succeeds ## Internal