args and -- and argv #46

Closed
defunkt wants to merge 1 commits from args-argv into main
Owner

Makes the args array only include args passed to your shrimp program. Use -- when passing args to the cli.

$ cat args.sh
#!/usr/bin/env shrimp
args | echo
$ ./args one two three
['one' 'two' 'three']
$ shrimp -E args -- one two three
['one' 'two' 'three']
$ shrimp -E argv
['/Users/chris/dev/projects/shrimp/bin/shrimp' '-E' 'argv']
$ ./argv.sh
['/Users/chris/dev/projects/shrimp/bin/shrimp' './argv.sh']
Makes the `args` array only include args passed to *your* shrimp program. Use `--` when passing args to the cli. ``` $ cat args.sh #!/usr/bin/env shrimp args | echo $ ./args one two three ['one' 'two' 'three'] $ shrimp -E args -- one two three ['one' 'two' 'three'] $ shrimp -E argv ['/Users/chris/dev/projects/shrimp/bin/shrimp' '-E' 'argv'] $ ./argv.sh ['/Users/chris/dev/projects/shrimp/bin/shrimp' './argv.sh'] ```
defunkt added 1 commit 2025-11-10 04:27:43 +00:00
Author
Owner

@probablycorey We need a better name than args, maybe? Because if you do args = blah in a script you're going to overwrite the global for your whole program.

Maybe $script.args ? We could then also add:

  • $script.path
  • $script.name

Or do we want to do Python-style and do __args__ or something? Kinda gross.

@probablycorey We need a better name than `args`, maybe? Because if you do `args = blah` in a script you're going to overwrite the global for your whole program. Maybe `$script.args` ? We could then also add: - `$script.path` - `$script.name` Or do we want to do Python-style and do `__args__` or something? Kinda gross.
Author
Owner

Oh yeah, can't do $script because that interferes with string interpolation.

Maybe a good place for CAPS? SCRIPT.name and ARGS and ARGV?

For now I'm going with just $, alone. We can change later if we come up with something more Shrimpy:

  • $.args
  • $.script.name
  • $.script.path
  • $.env
  • $.pid
  • $.cwd

($ is kinda fun because it's an s like... shrimp)

Oh yeah, can't do `$script` because that interferes with string interpolation. Maybe a good place for `CAPS`? `SCRIPT.name` and `ARGS` and `ARGV`? For now I'm going with *just* `$`, alone. We can change later if we come up with something more Shrimpy: - `$.args` - `$.script.name` - `$.script.path` - `$.env` - `$.pid` - `$.cwd` (`$` is kinda fun because it's an **s** like... shrimp)
Author
Owner

superseded by #49

superseded by #49
defunkt closed this pull request 2025-11-10 08:55:59 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: probablycorey/shrimp#46
No description provided.