lmi
[Top][All Lists]
Advanced

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

[lmi] Odd behavior with zsh


From: Greg Chicares
Subject: [lmi] Odd behavior with zsh
Date: Wed, 16 Dec 2015 17:02:57 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0

I've updated zsh:

$zsh --version
zsh 5.1.1 (i686-pc-cygwin)

Now I try using this command:

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;

which has always worked, and it still works in legitimate cases:

/lmi/src/lmi[0]$for z in ChangeLog ; 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;
20151216T1608Z

(Its effect is to 'touch' a file with its '$Id:' date.)

Now I try it in an illegitimate case, and it fails, which is okay:

/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;
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;’

However...at first I didn't realize that this file contains no '$Id:' date,
so I pressed up-arrow and tried modifying and re-executing the command:

/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
--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

and zsh spat back an old command. My latest command has no 'for' or 'grep',
but what zsh says mentions both, for instance.

Is there something in that last (manually issued) command that is somehow
interpreted as a reference to earlier command history?

I removed the history files in ~ and rebooted the VM, but the perceived
anomaly is still reproducible, even with a much simpler command:

/lmi/src/lmi[0]$<gwc/develop1.txt sed -e'/Id:/!d'
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;
/lmi/src/lmi[0]$

What am I missing?



reply via email to

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