Carets in script args require double-escaping on Windows

Open
#103 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
bash, clojure, powershell, shell, zsh

Research direction

Start by reproducing the issue with the shown foo.clj script after running bbin install foo.clj, then compare argument handling in zsh, bash, PowerShell, and cmd.exe. Trace the generated .bat wrapper path mentioned in the issue; done means a single caret reaches the script on Windows without requiring four carets, while Unix behavior remains unchanged.

Written by the indexing model from the issue text.

Description

Overview

On Windows, each bbin script has a .bat wrapper that interprets ^ in the args as an escape character. There appear to be two levels of escaping because you need to write ^^^^ to pass a single ^ to the bbin script. This problem doesn't happen on macOS/Linux because zsh and bash interpret ^ as a literal character.

I did a little research and I couldn't find an easy way to fix this while still keeping the .bat wrappers. I'm not sure how to fix this issue.

Steps to Reproduce

  1. Start with a script called foo.clj:
(prn *command-line-args*)
  1. Install the script:
$ bbin install foo.clj
  1. In zsh and bash, carets don't need to be escaped to be passed through:
    $ foo ^hello
    ("^hello")
    
    In PowerShell and cmd.exe, carets need to be escaped four times:
    $ foo ^hello
    ("hello")
    $ foo ^^hello
    ("hello")
    $ foo ^^^^hello
    ("^hello")
    
Dominant language
Clojure
Stars
195
Forks
15
Avg merge
1m
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from babashka/bbin

All issues in babashka/bbin

Similar issues

More Clojure issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.