[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: History modifier :p ignored prior to another history reference
From: |
Piotr Grzybowski |
Subject: |
Re: History modifier :p ignored prior to another history reference |
Date: |
Thu, 5 May 2016 20:08:39 +0200 |
Hey,
confirmed, this is what happens by construction.
this one is going to be tricky, expansion happens on the shell line, way
before it comes to execution. I do not see reparsing again at execute_command
even if we had means, which we dont, to store the information from history
expansion to know what to execute and what not. Re-tokenizing by rules of
history expansion anywhere outside histexpand seems out of place as much as
implementing shell lexer (again) in histexpand. Maybe splitting in
history_expand and returning tokens with options, that are later put together
for execution? Either way seems a bit large.
Currently the design indicates: :p applies to the whole line.
Maybe I am mistaken, correctly me if I am wrong.
cheers,
pg
On 3 May 2016, at 18:15, Dean Stanton wrote:
> 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-redhat-linux-gnu'
> -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
> -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include
> -I./lib -D_GNU_SOURCE -DRECYCLES_PIDS -O2 -g -pipe -Wall
> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
> --param=ssp-buffer-size=4 -m64 -mtune=generic
> uname output: Linux dstanton-vm.tintri.com 2.6.32.26-175.fc12.x86_64 #1 SMP
> Wed Dec 1 21:39:34 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
> Machine Type: x86_64-redhat-linux-gnu
>
> Bash Version: 4.0
> Patch Level: 38
> Release Status: release
>
> Description:
> History modifier :p is not honored when it appears prior to another history
> reference on the same command line.
>
> I tried to find a website with known bash bugs (to search to see if
> this issue was already discussed), but didn't find such a site.
>
> Repeat-By:
> $ echo one two three four
> one two three four
> $ echo !:2:p ; echo !$ # :p was ignored!
> echo two ; echo four
> two
> four
>
> $ echo one two three four
> one two three four
> $ echo !:p !! # :p was ignored!
> echo one two three four echo one two three four
> one two three four echo one two three four
>
>
> I expected the entire command line to be only printed and not
> executed. The manpage says
> p Print the new command but do not execute it.
> Instead, the :p was ignored and the entire command line was (printed
> and then) executed.
>
> $ echo one two three four
> one two three four
> $ echo !:2 ; echo !$:p # :p was heeded.
> echo two ; echo four
> $ echo one two three four
> $ echo !:1:p !$
> # :p was ignored
> echo one four
> one four
>
>