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

How to pass arguments to script? #6

Closed
jamespo opened this issue Apr 26, 2022 · 4 comments
Closed

How to pass arguments to script? #6

jamespo opened this issue Apr 26, 2022 · 4 comments

Comments

@jamespo
Copy link

jamespo commented Apr 26, 2022

I've skimmed the docs but can see how hush gets args the way bash puts them in $1, $2 etc?

script.hsh arg1 arg2 arg3

Ideally it would support a more powerful argument parser, like argparse in python or getopt.

@eterps
Copy link

eterps commented Apr 26, 2022

I was also looking for this. Ideally a newer shell would have argument parsing support that surpasses that of previous shells. For example for the Oil shell they are thinking in this direction: oils-for-unix/oils#469

@matu3ba
Copy link

matu3ba commented Apr 26, 2022

another question is how to do assignments to variables.
Is also let var = ... needed to have a faster path or is the more convenient/hacky var = ... possible?

@telemachus
Copy link

I've skimmed the docs but can see how hush gets args the way bash puts them in $1, $2 etc?

script.hsh arg1 arg2 arg3

Ideally it would support a more powerful argument parser, like argparse in python or getopt.

It looks like std.args() is what you need.

for item in std.iter(std.args()) do
    std.print(item)
end

@gahag
Copy link
Collaborator

gahag commented Apr 26, 2022

Correct, std.args() is the way to obtain an array of command line arguments. If you need more elaborate argument parsing, it can be implemented as a library in pure Hush.

@gahag gahag closed this as completed Apr 26, 2022
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

No branches or pull requests

5 participants