-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change fixes the history pruning treatment of a slash
character in the history followed by the name of the history command. The purpose of pruning is to avoid recursion in the history rewind, so history lines with a history command in them are pruned away in the search. With the history command named as "-", previously a history line like: find / --option would have been pruned (too aggressively). The change trims whitespace after first considering the case of whitespace separating a slash and the name of the history command. A few basic unit tests for the history command are also added with this commit.
- Loading branch information
Showing
14 changed files
with
154 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
all: -p --p \ | ||
ignore_me.test \ | ||
match_me_no_syntax.test \ | ||
match_me_slash_whitespace.test \ | ||
delete_char.test \ | ||
delete_char_stepwise.test \ | ||
insert_char.test \ | ||
insert_char_skip_tabs.test \ | ||
replace_space.test \ | ||
append_char.test \ | ||
truncate_and_append.test \ | ||
skip_match.test | ||
|
||
ignore_me.test: force | ||
@cp $(@:.test=) $@ | ||
history=$@ ./-p | cmp -n `sed 1q $@ | wc -c` - $@ | ||
@rm $@ | ||
|
||
match_me_no_syntax.test \ | ||
match_me_slash_whitespace.test: force | ||
@cp $(@:.test=) $@ | ||
history=$@ ./-p > $(@:.test=.out) && sed -n 2p $@ | cmp - $(@:.test=.out) | ||
@rm $@ $(@:.test=.out) | ||
|
||
delete_char.test \ | ||
delete_char_stepwise.test \ | ||
insert_char.test \ | ||
insert_char_skip_tabs.test \ | ||
replace_space.test \ | ||
append_char.test \ | ||
truncate_and_append.test \ | ||
skip_match.test: force | ||
@cp $(@:.test=) $@ | ||
sed -n -e /EOF/q -e 1d -e p $@ | history=$@ ./--p >$(@:.test=.out) 2>/dev/null && sed 1q $@ | cmp - $(@:.test=.out) | ||
@rm $@ $(@:.test=.out) | ||
|
||
-p --p: | ||
ln -s ../history $@ | ||
|
||
force: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
append the second the | ||
+ the | ||
|
||
EOF | ||
append the second |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
delete the second the | ||
#### | ||
|
||
EOF | ||
delete the the second the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
delete the second the | ||
# | ||
# | ||
# | ||
# | ||
|
||
EOF | ||
delete the the second the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
the cases below should all be ignored | ||
- | ||
-- | ||
-p | ||
--p | ||
./- | ||
./-- | ||
./-p | ||
./--p | ||
- | ||
-- | ||
-p | ||
--p | ||
./- | ||
./-- | ||
./-p | ||
./--p | ||
{-} | ||
{--} | ||
{-p} | ||
{--p} | ||
{ -} | ||
{ --} | ||
{ -p} | ||
{ --p} | ||
(-) | ||
(--) | ||
(-p) | ||
(--p) | ||
( -) | ||
( --) | ||
( -p) | ||
( --p) | ||
()- | ||
()-- | ||
()-p | ||
()--p | ||
@- | ||
@-- | ||
@-p | ||
@--p | ||
@ - | ||
@ -- | ||
@ -p | ||
@ --p | ||
|- | ||
|-- | ||
|-p | ||
|--p | ||
`- | ||
`-- | ||
`-p | ||
`--p | ||
` - | ||
` -- | ||
` -p | ||
` --p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
insert the first the | ||
^the | ||
|
||
EOF | ||
insert first the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
insert after a combination of spaces and tabs near the last position | ||
^near the last | ||
|
||
EOF | ||
insert after a combination of spaces and tabs position |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
this should match | ||
echo -- -n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
this should match | ||
find / -- -ls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
replace spaces | ||
%%% | ||
|
||
EOF | ||
replace the spaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
append the second the | ||
- | ||
- | ||
+ the | ||
|
||
EOF | ||
append the second | ||
skip this line | ||
skip this line, too |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
truncate and append | ||
$ and append | ||
|
||
EOF | ||
truncate this old stuff |