Bug #586
closedsed -i should take an "optional" argument
0%
Description
As much as I hate this....
GNU sed allows -i to take an argument, but does not require it. We should observe the same GNU behavior for increased compatibility.
Note that there is no elegant way (that I could discover) to properly support this with getopt... the optional argument should be optional only for -i, and should be treated as an argument to -i only when used without intervening spaces. This is apparently POSIX compliant, although it violates the CLIP standard.
I'd recommend making a minor enhancement to getopt to support this, or perhaps extending getopt_long.
Related issues
Updated by Gordon Ross over 12 years ago
One could also just not use getopt for this program.
Parsing argv options by hand is not that hard.
Updated by Roland Mainz over 12 years ago
Gordon Ross wrote:
One could also just not use getopt for this program.
Parsing argv options by hand is not that hard.
Groan... please don't do that.
Right the Illumos userland is already suffering from the issues with non-uniform argument parsing and related problems. We're basically back to pre-SystemV times in that area. If we have a shared library function for this avoiding it is IMO bloat.
Updated by Yuri Pankov over 11 years ago
- Assignee deleted (
Roland Mainz) - Difficulty set to Medium
- Tags set to needs-triage
This shouldn't be hard to "fix" (adding :: style options to our getopt), but we need to define which behavior we want -
current:
sed -i.bak .... sed -i .bak .... but not sed -i ....
or GNU's:
sed -i ... sed -i.bak but not sed -i .bak ...
I don't see a way to make it compatible for both cases.
Updated by Garrett D'Amore over 11 years ago
Unfortunately, we have to support the GNU syntax. Ick. But that's what is needed for compatibility.
Updated by Yuri Pankov over 11 years ago
- Assignee set to Yuri Pankov
Much to my surprise, we have getopt_long() having all required functionality.. will post webrev shortly.
Updated by Gordon Ross over 11 years ago
- Status changed from New to Resolved
changeset: 13507:aaf06453aff9 tag: tip user: Yuri Pankov <yuri.pankov@nexenta.com> date: Fri Nov 04 12:59:45 2011 +0400 description: 586 sed -i should take an "optional" argument Reviewed by: Andrew Stormont <Andrew.Stormont@nexenta.com> Reviewed by: Kartik Mistry <kartik.mistry@gmail.com> Approved by: Gordon Ross <gwr@nexenta.com>