New flag option request

2011-10-20 Thread Bruce Korb

You may have this in the queue already, but just in case:

POSIX now specifies that if a standard utility has extended options,
then you accomplish it with ``-W option-name[=opt-arg]''.
I wouldn't care, but I wanted to add ``--noprofile --norc''
to the command line and, for debugging purposes, I aliased "bash"
to "bash -x".  Oops.  Two issues:

1. I'd be nice to be able to interleave short and long options, and
2. "bash -x -W noprofile -W norc" should also work.

Thank you so much!  Regards, Bruce



Re: New flag option request

2011-10-20 Thread Eric Blake

On 10/20/2011 08:48 AM, Bruce Korb wrote:

You may have this in the queue already, but just in case:

POSIX now specifies that if a standard utility has extended options,
then you accomplish it with ``-W option-name[=opt-arg]''.


Not quite.  POSIX specifies only that -W is reserved for 
implementation-defined extensions.  glibc's getopt_long _happens_ to 
have the implementation-defined extension that '-W foo' is equivalent to 
'--foo', so it would make sense that bash support the same extension as 
glibc for consistency among GNU programs, but that is _not_ a POSIX 
requirement.



I wouldn't care, but I wanted to add ``--noprofile --norc''
to the command line and, for debugging purposes, I aliased "bash"
to "bash -x". Oops. Two issues:

1. I'd be nice to be able to interleave short and long options, and
2. "bash -x -W noprofile -W norc" should also work.


Bash currently doesn't use getopt_long for option parsing, but rolls its 
own parser.  A patch to make the bash parser support mixed long and 
short options would also be welcome in my mind.


--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



Re: New flag option request

2011-10-20 Thread Chet Ramey
On 10/20/11 10:48 AM, Bruce Korb wrote:
> You may have this in the queue already, but just in case:
> 
> POSIX now specifies that if a standard utility has extended options,
> then you accomplish it with ``-W option-name[=opt-arg]''.

That's not actually published anywhere.  Where's the specification?

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: New flag option request

2011-10-20 Thread Bruce Korb

On 10/20/11 08:12, Chet Ramey wrote:

On 10/20/11 10:48 AM, Bruce Korb wrote:

You may have this in the queue already, but just in case:

POSIX now specifies that if a standard utility has extended options,
then you accomplish it with ``-W option-name[=opt-arg]''.


That's not actually published anywhere.  Where's the specification?


In my mind.  It is *reserved* for that purpose and I misremembered.
If it is reserved for that purpose, it may as well be used for that
purpose, though. :)



"history -s" within PROMPT_COMMAND deletes last history item.

2011-10-20 Thread lester
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' 
-DCONF_VENDOR='unknown' -DLOCALEDIR='/home/lester/base/share/locale' 
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -g -O2
uname output: Linux vmw-les.eng.vmware.com 2.6.40.6-0.fc15.x86_64 #1 SMP Tue 
Oct 4 00:39:50 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu

Bash Version: 4.2
Patch Level: 10
Release Status: release

Description:
The "history -s" usually removes the last history item which
is usually the "history -s" command itself, but PROMPT_COMMAND
disables history and causes an unrelated command to be deleted.

Repeat-By:
$ history -s '# line 1' ; history -s '# line 2' ; history 2
X1 # line 1
X2 # line 2
$ PROMPT_COMMAND="history -s '# line 3' ; history -s '# line 4'"
$ history 5
X1 # old command
X2 # line 1
X3 # line 2
X4 # line 3
X5 # line 4

Expect:
X1 # line 1
X2 # line 2
X3 PROMPT_COMMAND="history -s '# line 3' ; history -s '# line 4'"
X4 # line 3
X5 # line 4

No new commands will enter history as they are replaced with $'# line 
3\n# line 4'

Fix:
Either add a switch to disable the deletion, or stop the
 auto-delete when history is disabeled in:
parse.y 2466: parse_and_execute (savestring (command), vname, 
SEVAL_NONINT|SEVAL_NOHIST);