Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macros sh and sh< for running commands in a real shell #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MaxGyver83
Copy link

Use these macros to run commands in a shell (sh). This allows using shell variables, cd and other shell builtins.

Examples:

(import sh)

(sh/sh cd /tmp && git clone https://github.com/andrewchambers/janet-sh)

(sh/sh<
  if [ "${USER}" = ,(os/getenv "USER") ];
  then echo "it's \"me\""; else echo "not me"; fi)

These things don't work:

  • (sh/sh< echo 'test') (text in single quotes) → Use double quotes or no quotes at all.
  • (sh/sh< echo hello\ world) (escaping spaces) → Write (sh/sh< echo "hello world") instead.
  • (sh/sh< echo \$PWD) (escaping dollar signs) → Use (sh/sh< echo `\$PWD`) instead.
  • Probably other things.

To be discussed

  • The new function collect-proc-specs-subshell is very similar (and based on) collect-proc-specs. Potential code duplication!?
  • Might be needed for sake of completeness: sh?, sh<_, bash, bash<, bash?, bash<_!?

This addresses #21 and #22.

Use these macros to run commands in a shell (`sh`). This allows using shell variables, `cd` and other shell builtins.
@MaxGyver83 MaxGyver83 changed the title Add macros sh and sh< for running command in a real shell Add macros sh and sh< for running commands in a real shell Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant