-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
feature request: POSIX shell compliance #31
Comments
AFAIK, when your script accepts only positional arguments, the generated code is POSIX-compliant. Try and correct me if I am wrong! |
Sorry, but no, not at all. You use many bash features like So pasting your example code (for pos. arg. only, and
|
The "referenced, but not assigned" errors can be mitigated by using the ARG_DEFAULTS_POS() macro. I have mentioned that if you don't use positional arguments, there are no arrays, so the script is POSIX compliant except the
|
Only the output basically, what the script itself uses does hardly matter IMHO. And why one needs the output to be compatible should be clear: if your own script needs to be compatible or you just want it to be compatible for whatever strange reason (😉), this small output should be compatible, too. The best case would be to just have a command line switch |
I'm a habitual |
I plan to slightly refactor Argbash, so it is easier to add other outputs, such as POSIX output scripts, bash completion and manpage templates. I am grateful that you consider contributing to Argbash, and I recommend you to postpone your contribution for a week or two, when the refactoring is completed. |
@matejak absolutely, and thanks very much for even considering this. |
@matejak, how's the refactor coming? |
The refactoring is not perfect, but it allows to writing of another outputs with relative ease. As the POSIX output seems to be important for quite a few people, I will also dedicate some time and energy to accomplish the goal. I propose to identify what Argbash is able to accomplish now and how to achieve as much of it as possible while restricting to POSIX compliant shell code only. I think that even some of the current code could be more POSIX-friendly. Then, depending on the involvement you want to have, we can craft more concrete steps forward. If you want, you can proceed with the first part right here in this issue. |
Wow, @matejak, this is harder than it looks. Do I understand correctly that the |
I am also a bit surprised. Yet again let me say it is really enough, if the output is POSIX. |
@rugk , I think the current mechanism would force the removal of all Bashisms within https://github.com/matejak/argbash/blob/master/bin/argbash#L231 And probably any references thereto. |
I am not sure if I understand you. I think that it is not worth the effort to make the |
Ah, certainly. Okay, let's use the minimal example and put a fine point how the generated script is non-compliant. To clarify, I'm testing within an
Then, I iterate though the errors, "fixing" or commenting them out as I progress. What follow are the (dash-specific) errors I encountered before my fixes started interfering with the actual execution:
Some thoughts regarding the treatment of positional arguments... For the positional argument counting within For the positional argument name definitions within |
@Rubicks Your output got somehow mangled. |
@matejak , assume you have the following positional argument variable names in a temporary file like this:
Let us further assume you have the following positional argument values in a temporary file like this:
To (pairwise) assign the latter values to the former variable names, you could do something like this:
|
So from the looks of things the POSIX output is quite close. It looks like that it will use |
@matejak, what's the "correct" thing to do when a user requests posix-compliant output and long options? Error out with a message like "I can't do that"? |
Strict POSIX-compliance means that no long options are allowed in the first place - they are a GNU extension. Therefore, I think that I will just make sure that every optional argument has a short option, and the help message will tell the rest of the story. |
The |
Resolved by #48 |
It would be nice if argbash is able to produce portable POSIX-compliant scripts that can also parse long options. For what it's worth, it does seem to be possible. I've only tried running it on |
Would an option to support the generation of POSIX-compliant shell code be too much? Genuinely asking because I'm curious and trying to gauge interest.
The text was updated successfully, but these errors were encountered: