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

Write wrappers for all POSIX utils that support GNU-style long options #464

Closed
andychu opened this issue Aug 17, 2019 · 3 comments
Closed

Comments

@andychu
Copy link
Contributor

andychu commented Aug 17, 2019

I have been thinking this for awhile, but this thread brought it to the forefront:

https://news.ycombinator.com/item?id=20724679

For example, you would have a shell function cut that does all the parsing, and calls the real command in backward compatible form:

var cut_spec = ... # define flags like --delimiter

cut() {
   # ... parse "$@", supporting --delimiter instead of -d
   var opts = cut_spec.Parse()
   var argv = SerializeToPOSIX(opts)

   command cut @argv  # call the external tool
}

This makes shell scripts more readable, while not sacrificing compatibility with POSIX.

It also helps with embedded systems (busybox / toybox), not just BSDs.


(It's possible to do this with pure POSIX shell via some code gen, but I'm not sure I want to go there. I'd rather test out the Oil option parser.)

@drwilly
Copy link
Contributor

drwilly commented Aug 18, 2019

Do the cut_spec.Parse() etc. functions already exist?

@andychu
Copy link
Contributor Author

andychu commented Aug 19, 2019

They don't exist. I just filed #469 to add this API. I think I have a decent design, but it might take awhile to get to it unfortunately... That issue is blocking this one :-/

@andychu
Copy link
Contributor Author

andychu commented Jan 6, 2022

Too far off

@andychu andychu closed this as completed Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants