POSIX and GNU have their syntax styles for options. For all the commands that I have seen, they accept option-like inputs as command line arguments.
Is it uncommon for a program to accept option-like inputs from stdin (and therefore to use getopt
to parse option-like stdin inputs) ? Something like:
$ ls -l
-rw-rw-r-- 1 t t 31232 Jan 7 13:38 fetch.png
-rw-rw-r-- 1 t t 69401 Feb 6 14:35 proxy.png
$ myls
> -l
-rw-rw-r-- 1 t t 31232 Jan 7 13:38 fetch.png
-rw-rw-r-- 1 t t 69401 Feb 6 14:35 proxy.png
> -l fetch.png
-rw-rw-r-- 1 t t 31232 Jan 7 13:38 fetch.png
Why is it uncommon for stdin inputs to have option-like inputs, while common for command line arguments?
From expressive power point of view (similar to regular languages vs context free languages), are nonoption like inputs and option like inputs equivalent?
Let's not emphasize on shell expansions, because we never expect (or need) something like shell expansion happen on stdin input (nonoption like).
Thanks.
Similar questions for nonoption like inputs: https://stackoverflow.com/questions/54584124/how-to-parse-non-option-command-line-arguments-and-stdin-inputs (The post is removed due to no response and downvotes. but still accessible if you have sufficient reputations)
stdin
? – Andrew Henle Feb 07 '19 at 23:52parted
andadduser
do provide such functionality, but they can't be used in script like that – 炸鱼薯条德里克 Feb 08 '19 at 01:23parted
andadduser
accepting option inputs from stdin? Can't they use non-option like inputs in place of option like inputs? Do non-option like inputs in place of option like inputs have the same expressive power (formal language concept)? – Tim Feb 08 '19 at 01:31