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

Introduction of posix output [WIP] #48

Merged
merged 17 commits into from
Jun 29, 2018
Merged

Introduction of posix output [WIP] #48

merged 17 commits into from
Jun 29, 2018

Conversation

matejak
Copy link
Owner

@matejak matejak commented Mar 19, 2018

This PR aims to implement the posix script output as introduced in #31.
The work can be logically divided into two cathegories:

  • Common effort towards reducing usage of arrays both for posix and bash outputs.
  • Specialized effort to introduce specialized versions of macros specific to the POSIX output.

@the-real-neil
Copy link

I have yet to test this patch, but it looks completely different than what I was expecting --- in a good way. You may have inspired me to get back into m4 hacking.

@the-real-neil
Copy link

It's not working for me:

$ ./bin/argbash -t posix-script - <resources/examples/minimal.m4 >minimal.sh && sh minimal.sh
minimal.sh: 37: minimal.sh: Syntax error: "(" unexpected

@matejak matejak changed the title Introduction of posix output Introduction of posix output [WIP] Apr 2, 2018
@matejak
Copy link
Owner Author

matejak commented Apr 2, 2018

Thank you for following, this work is still a WIP and it will take some time.
I have to say that I am not comfortable writing and reading from the disc just to get arguments parsed, so I will think further of how to do that. There is the positional args array and the local keyword that have to be dealt with and unless those are addressed, it won't work.
Some of the work could be nicely resolved by going for the strict POSIX compliance (i.e. scripts aren't allowed to use long options and there can't be optional args after the first positional argument). Then, Argbash could generate a parsing loop that would use getopts, which would be pretty neat. Let's see...
m4 is a fascinating language and its extension m4sugar is even quite nice to use, so I am happy to hear that :-)

@the-real-neil
Copy link

the-real-neil commented Apr 3, 2018

Regarding the use of temporary files to implement argument parsing: it's a trick I use often in my own scripting but it's a poor fit for argbash if your intent is to avoid dependencies on any file system.

Regarding your point about getopts: while its presence is guaranteed by POSIX, I think sacrificing long options is a mistake. You've already done the considerable work in implementing your own argument parsing mechanism. If it can be adapted to avoid Bashisms, then all kinds of shells stand to benefit, not just the strictly POSIX-compliant ones.

@the-real-neil
Copy link

@matejak , this is probably the least of your concerns, but the local keyword is not POSIX. dash tolerates it, though.

@matejak
Copy link
Owner Author

matejak commented Apr 16, 2018

That's fine, I am very close to getting rid of local for POSIX output.

@matejak
Copy link
Owner Author

matejak commented Jun 29, 2018

The POSIX output is now generally usable and just needs some polishing.

@matejak matejak merged commit 0711d0c into master Jun 29, 2018
@matejak matejak deleted the posix-output branch January 5, 2019 15:52
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.

2 participants