* I broke my !$
@ 2011-10-05 11:41 Jay Levitt
2011-10-05 12:19 ` Daniel Shahaf
2011-10-05 16:05 ` Bart Schaefer
0 siblings, 2 replies; 6+ messages in thread
From: Jay Levitt @ 2011-10-05 11:41 UTC (permalink / raw)
To: zsh-users
After playing with zsh_add_history, or possibly at some time before
then, I broke !$...
% ls ~/.zsh_history
/Users/jay/.zsh_history
% ls !$
ls ls ~/.zsh_history
ls: ls: No such file or directory
/Users/jay/.zsh_history
What'd I do?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: I broke my !$
2011-10-05 11:41 I broke my !$ Jay Levitt
@ 2011-10-05 12:19 ` Daniel Shahaf
2011-10-05 15:48 ` Julien Nicoulaud
2011-10-05 16:05 ` Bart Schaefer
1 sibling, 1 reply; 6+ messages in thread
From: Daniel Shahaf @ 2011-10-05 12:19 UTC (permalink / raw)
To: Jay Levitt; +Cc: zsh-users
Jay Levitt wrote on Wed, Oct 05, 2011 at 07:41:29 -0400:
> What'd I do?
Binary search your zshrc?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: I broke my !$
2011-10-05 12:19 ` Daniel Shahaf
@ 2011-10-05 15:48 ` Julien Nicoulaud
2011-10-05 16:13 ` Bart Schaefer
0 siblings, 1 reply; 6+ messages in thread
From: Julien Nicoulaud @ 2011-10-05 15:48 UTC (permalink / raw)
To: Daniel Shahaf; +Cc: Jay Levitt, zsh-users
[-- Attachment #1: Type: text/plain, Size: 541 bytes --]
Same for me, messing with zsh_add_history hook breaks history expansion:
history_strip_passwords() {
# Strip out -Dgpg.passphrase option value (Maven)
print -sr "${${1%%$'\n'}//(#b)(gpg.passphrase=)*[:space:]/$match[1]}"
fc -p
}
add-zsh-hook zshaddhistory history_strip_passwords
With this hook, history exapnsions like "!$" or "!!" always return the whole
history line...
2011/10/5 Daniel Shahaf <d.s@daniel.shahaf.name>
> Jay Levitt wrote on Wed, Oct 05, 2011 at 07:41:29 -0400:
> > What'd I do?
>
> Binary search your zshrc?
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: I broke my !$
2011-10-05 15:48 ` Julien Nicoulaud
@ 2011-10-05 16:13 ` Bart Schaefer
2011-10-31 16:26 ` Jay Levitt
0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2011-10-05 16:13 UTC (permalink / raw)
To: zsh-users
On Oct 5, 5:48pm, Julien Nicoulaud wrote:
}
} Same for me, messing with zsh_add_history hook breaks history expansion:
Aha.
} history_strip_passwords() {
} # Strip out -Dgpg.passphrase option value (Maven)
} print -sr "${${1%%$'\n'}//(#b)(gpg.passphrase=)*[:space:]/$match[1]}"
} fc -p
} }
} add-zsh-hook zshaddhistory history_strip_passwords
}
} With this hook, history exapnsions like "!$" or "!!" always return the whole
} history line...
You need to either remove the double quotes or use "print -S". With the
quotes and the lower-case -s you are making a history entry that has
exactly one word consisting of the entire command.
-s
Place the results in the history list instead of on the
standard output. Each argument to the print command is
treated as a single word in the history, regardless of its
content.
-S
Place the results in the history list instead of on the
standard output. In this case only a single argument is
allowed; it will be split into words as if it were a full
shell command line. The effect is similar to reading the
line from a history file with the HIST_LEX_WORDS option
active.
It's possible that you have a version of zsh that has the history hook
but not the -S option of print. In that event you probably also have a
buggy ${(z)...} so there's no immediate workaround that comes to mind.
Something involving writing it to a different history file and then
reading back with "fc -R" might work.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: I broke my !$
2011-10-05 16:13 ` Bart Schaefer
@ 2011-10-31 16:26 ` Jay Levitt
0 siblings, 0 replies; 6+ messages in thread
From: Jay Levitt @ 2011-10-31 16:26 UTC (permalink / raw)
To: Bart Schaefer; +Cc: zsh-users
Picking this up... Yes, I modified zsh_add_history hook; see
thediscussion under "zshaddhistory confusion". So what I have now
isthis:
function zshaddhistory() { print -sr -- "${1%%$'\n'}" fc -p
~/.zsh_history_detail print -sr -- "${1%%$'\n'} ### ${PWD} $(date
'+%Y-%m-%d %R')" return 1}
which seems to support the "you need print -S" theory. I have
4.3.12,but it doesn't have -S; is that something only on trunk right
now? Istrunk stable enough for average daily use?
I'm on zsh 4.3.12.
On Wed, Oct 5, 2011 at 12:13 PM, Bart Schaefer
<schaefer@brasslantern.com> wrote:
> On Oct 5, 5:48pm, Julien Nicoulaud wrote:
> }
> } Same for me, messing with zsh_add_history hook breaks history expansion:
>
> Aha.
>
> } history_strip_passwords() {
> } # Strip out -Dgpg.passphrase option value (Maven)
> } print -sr "${${1%%$'\n'}//(#b)(gpg.passphrase=)*[:space:]/$match[1]}"
> } fc -p
> } }
> } add-zsh-hook zshaddhistory history_strip_passwords
> }
> } With this hook, history exapnsions like "!$" or "!!" always return the whole
> } history line...
>
> You need to either remove the double quotes or use "print -S". With the
> quotes and the lower-case -s you are making a history entry that has
> exactly one word consisting of the entire command.
>
> -s
> Place the results in the history list instead of on the
> standard output. Each argument to the print command is
> treated as a single word in the history, regardless of its
> content.
>
> -S
> Place the results in the history list instead of on the
> standard output. In this case only a single argument is
> allowed; it will be split into words as if it were a full
> shell command line. The effect is similar to reading the
> line from a history file with the HIST_LEX_WORDS option
> active.
>
> It's possible that you have a version of zsh that has the history hook
> but not the -S option of print. In that event you probably also have a
> buggy ${(z)...} so there's no immediate workaround that comes to mind.
> Something involving writing it to a different history file and then
> reading back with "fc -R" might work.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: I broke my !$
2011-10-05 11:41 I broke my !$ Jay Levitt
2011-10-05 12:19 ` Daniel Shahaf
@ 2011-10-05 16:05 ` Bart Schaefer
1 sibling, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2011-10-05 16:05 UTC (permalink / raw)
To: zsh-users
On Oct 5, 7:41am, Jay Levitt wrote:
}
} After playing with zsh_add_history, or possibly at some time before
} then, I broke !$...
}
} % ls !$
} ls ls ~/.zsh_history
First check whether you broke history itself? That is, if you recall
the command line with ctl-p or list it with the "history" command, is
the first word already doubled? If so, it's probably something to do
with a zshaddhistory hook function.
Next check the value of $histchars -- I'm not sure how this would get
that specific result, but it's another way to break history. [*]
Nothing else comes to mind just now. Selectively disabling parts of
your startup until you find a culprit as suggested by Daniel is the
most certain way to track it down.
[*] For example, if the first character of histchars is '$' then you
can't get the equivalent of !! any more, because in $$ the second $
is interpreted as a word designator "the last argument" instead of
as the event designator "the previous command".
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-10-31 16:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-05 11:41 I broke my !$ Jay Levitt
2011-10-05 12:19 ` Daniel Shahaf
2011-10-05 15:48 ` Julien Nicoulaud
2011-10-05 16:13 ` Bart Schaefer
2011-10-31 16:26 ` Jay Levitt
2011-10-05 16:05 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).