Skip to content

docs(nushell): add script and path rules - #20

Merged
hakula139 merged 6 commits into
mainfrom
docs/nushell-traps
Nov 10, 2026
Merged

hakula139 merged 6 commits into
mainfrom
docs/nushell-traps

Conversation

@hakula139

@hakula139 hakula139 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Summary

The nushell skill gains two traps from recent devkit work and rules for path joins and script-relative paths, and its script-argument trap now names the three argument shapes that run as code on Nushell 0.116.1, followed by a defensive rule.

  • Script arguments: nu <script> <args> re-parses the arguments as source text and leaves three shapes unquoted, as nushell/nushell#19484 reports: a -- argument's name part, a bare redirection token, and an argument starting with ...$. The trap names each with a harmless example, then tells writers never to pass an untrusted string as a script argument, and to pass it through stdin, an environment variable, or a file, or check it against an allowlist pattern first. The old bullet named only the first shape and put the burden on callers to avoid it.
  • Subcommand flags: a flag on def main does not reach def "main <sub>", so script sub --flag fails with an unknown flag and script --flag sub passes sub to main.
  • | ignore: piping an external command into ignore discards its exit status, so the script continues and can exit 0.
  • Path joins: a literal relative path goes to path join as one /-separated string, as in path join "libexec/gnubin", with a separate argument only for each segment from a variable. This matches the single-string form that comparable Nushell scripts use. The two joins in nix/check-skills.nu that split a literal run now follow the rule.
  • Script-relative paths: files beside a script are located through a named path self constant at the top, such as const SCRIPT_DIR = path self ".", since path self runs only at parse time and names the file it appears in, while $env.FILE_PWD and $env.CURRENT_FILE point at the running script even inside a module.

Bump hakula-languages to 1.0.5.

Test plan

  • Commit and push hooks, and nix develop -c run-hooks
  • nix flake check --all-systems
  • claude plugin validate .
  • On the dev shell's Nushell 0.116.1, def main [x] reports int for nu script.nu 8 and bool for true, each of the three shapes runs as code with a harmless print or redirection to a scratch file, a --name=value argument stays quoted, and data passed through --stdin or an environment variable arrives as a plain string
  • nu script.nu sub --verbose fails with nu::parser::unknown_flag and nu script.nu --verbose sub with nu::parser::extra_positional when only main declares --verbose
  • path join "libexec/gnubin" and path join "libexec" "gnubin" yield the same path
  • Run from another directory, const SCRIPT_DIR = path self "." gives the script's directory, a module's path self gives the module's directory, the module's $env.CURRENT_FILE gives the main script, and an inline path self inside main fails with this command can only run during parse-time
  • A script running ^false | ignore and then print prints and exits 0, while ^false | lines ends it with exit 1
  • GitHub CI: Linux, macOS, and CI Result

Replace the argument-splicing trap with a defensive rule against passing untrusted strings as script arguments, and add traps for flags on def main, which subcommands do not inherit, and for piping an external command into ignore, which hides its failure. Bump hakula-languages to 1.0.5.
@hakula139 hakula139 added the documentation Documentation changes label Nov 10, 2026
@hakula139 hakula139 self-assigned this Nov 10, 2026
@hakula139 hakula139 changed the title docs(nushell): add script argument and ignore traps docs(nushell): add script argument, ignore, and path join rules Nov 10, 2026
@hakula139 hakula139 changed the title docs(nushell): add script argument, ignore, and path join rules docs(nushell): add script argument, ignore, and path rules Nov 10, 2026
Nushell now tracks the behaviour publicly in nushell/nushell#19484, so the trap names the three shapes with harmless examples before the defensive rule.
Qualify the flag-name example, list the three argument shapes with semicolons, name FILE_PWD beside CURRENT_FILE, and join the plugin manifest path's literal run as one string.
@hakula139 hakula139 changed the title docs(nushell): add script argument, ignore, and path rules docs(nushell): add script and path rules Nov 10, 2026
@hakula139
hakula139 merged commit 52a4697 into main Nov 10, 2026
3 checks passed
@hakula139
hakula139 deleted the docs/nushell-traps branch November 10, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant