lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Odd behavior with zsh


From: Vadim Zeitlin
Subject: Re: [lmi] Odd behavior with zsh
Date: Wed, 16 Dec 2015 20:04:11 +0100

On Wed, 16 Dec 2015 17:02:57 +0000 Greg Chicares <address@hidden> wrote:

GC> I've updated zsh:
GC> 
GC> $zsh --version
GC> zsh 5.1.1 (i686-pc-cygwin)

 FWIW I have the same version in my VM but only 5.0.8 on my main system.

GC> Now I try using this command:
GC> 
GC> for z in * ; do grep --quiet --files-with-matches '$Id:' $z && touch 
"--date=$(<$z sed -e'/$Id:/!d' |sed -e's/^.* [0-9][0-9]* \([0-9]\{4\}[-0-9: 
]*\).*$/\1/')" $z && date -u +'%Y%m%dT%H%MZ' -r $z; done;
GC> 
GC> which has always worked,

 Off topic, but I'd replace "*" above with "*(.)" to avoid grepping
directories, which results in errors.

GC> Now I try it in an illegitimate case, and it fails, which is okay:
GC> 
GC> /lmi/src/lmi[2]$for z in gwc/develop1.txt ; do grep --quiet 
--files-with-matches '$Id:' $z && touch "--date=$(<$z sed -e'/$Id:/!d' |sed 
-e's/^.* [0-9][0-9]* \([0-9]\{4\}[-0-9: ]*\).*$/\1/')" $z && date -u 
+'%Y%m%dT%H%MZ' -r $z; done;
GC> touch: invalid date format ‘for z in * ; do grep --quiet 
--files-with-matches '$Id:' $z && touch "--date=$(<$z sed -e'/$Id:/!d' |sed 
-e's/^.* [0-9][0-9]* \\([0-9]\\{4\\}[-0-9: ]*\\).*$/\\1/')" $z && date -u 
+'%Y%m%dT%H%MZ' -r $z; done;\nfor z in * ; do grep --quiet --files-with-matches 
'$Id:' $z && touch "--date=$(<$z sed -e'/$Id:/!d' |sed 
-e's/^.*\\([0-9]\\{4\\}[0-9\\/: ]*\\) .*$/\\1/')" $z && date -u +'%Y%m%dT%H%MZ' 
-r $z; done;’
GC> 
GC> However...at first I didn't realize that this file contains no '$Id:' date,
GC> so I pressed up-arrow and tried modifying and re-executing the command:
GC> 
GC> /lmi/src/lmi[1]$z=gwc/develop1.txt ; echo "--date=$(<$z sed -e'/$Id:/!d' 
|sed -e's/^.* [0-9][0-9]* \([0-9]\{4\}[-0-9: ]*\).*$/\1/')" $z
GC> --date=for z in * ; do grep --quiet --files-with-matches '$Id:' $z && touch 
"--date=$(<$z sed -e'/$Id:/!d' |sed -e's/^.* [0-9][0-9]* \([0-9]\{4\}[-0-9: 
]*\).*$/\1/')" $z && date -u +'%Y%m%dT%H%MZ' -r $z; done;
GC> for z in * ; do grep --quiet --files-with-matches '$Id:' $z && touch 
"--date=$(<$z sed -e'/$Id:/!d' |sed -e's/^.*\([0-9]\{4\}[0-9\/: ]*\) .*$/\1/')" 
$z && date -u +'%Y%m%dT%H%MZ' -r $z; done; gwc/develop1.txt
GC> 
GC> and zsh spat back an old command. My latest command has no 'for' or 'grep',
GC> but what zsh says mentions both, for instance.

 I am not sure if I understand correctly what happens here but for me, if I
enter the command copy and pasted from above, press "Enter" and then "Up",
I get exactly the same command back:

---------------------------------- >8 --------------------------------------
% z=gwc/develop1.txt ; echo "--date=$(<$z sed -e'/$Id:/!d' |sed -e's/^.* 
[0-9][0-9]* \([0-9]\{4\}[-0-9: ]*\).*$/\1/')" $z
# Enter pressed
--date=for z in * ; do grep --quiet --files-with-matches '$Id:' $z && touch 
"--date=$(<$z sed -e'/$Id:/!d' |sed -e's/^.* [0-9][0-9]* \([0-9]\{4\}[-0-9: 
]*\).*$/\1/')" $z && date -u +'%Y%m%dT%H%MZ' -r $z; done;
for z in * ; do grep --quiet --files-with-matches '$Id:' $z && touch 
"--date=$(<$z sed -e'/$Id:/!d' |sed -e's/^.*\([0-9]\{4\}[0-9\/: ]*\) .*$/\1/')" 
$z && date -u +'%Y%m%dT%H%MZ' -r $z; done; gwc/develop1.txt
%
# Up pressed
% z=gwc/develop1.txt ; echo "--date=$(<$z sed -e'/$Id:/!d' |sed -e's/^.* 
[0-9][0-9]* \([0-9]\{4\}[-0-9: ]*\).*$/\1/')" $z
---------------------------------- >8 --------------------------------------

Of course, the _output_ of this command still contains "for" and "grep"
because this is what comes from gwc/develop1.txt file. But the command
itself doesn't change for me, does it really do this for you?

GC> I removed the history files in ~ and rebooted the VM, but the perceived
GC> anomaly is still reproducible, even with a much simpler command:
GC> 
GC> /lmi/src/lmi[0]$<gwc/develop1.txt sed -e'/Id:/!d'
GC> for z in * ; do grep --quiet --files-with-matches '$Id:' $z && touch 
"--date=$(<$z sed -e'/$Id:/!d' |sed -e's/^.* [0-9][0-9]* \([0-9]\{4\}[-0-9: 
]*\).*$/\1/')" $z && date -u +'%Y%m%dT%H%MZ' -r $z; done;
GC> for z in * ; do grep --quiet --files-with-matches '$Id:' $z && touch 
"--date=$(<$z sed -e'/$Id:/!d' |sed -e's/^.*\([0-9]\{4\}[0-9\/: ]*\) .*$/\1/')" 
$z && date -u +'%Y%m%dT%H%MZ' -r $z; done;
GC> /lmi/src/lmi[0]$
GC> 
GC> What am I missing?

 I'm sorry, I don't really understand what the problem is. All I can say is
that if you suspect anything wrong with the shell, you should run it with
"--no-globalrcs --no-rcs" flags to ensure that it's not due to something in
your startup files.

 Regards,
VZ

reply via email to

[Prev in Thread] Current Thread [Next in Thread]