Fixed following bugs in history function:

1. history function without any argument now correctly shows user's command history.
2. history --save now saves user's command history.
This commit is contained in:
Siteshwar Vashisht
2012-06-06 20:51:37 +05:30
parent c0085cbc61
commit 1078ad9ae9

View File

@@ -23,13 +23,18 @@ function history --description "Deletes an item from history"
case --contains case --contains
set search_mode contains set search_mode contains
set contains_args $argv[(math $i + 1)] set contains_args $argv[(math $i + 1)]
case --save
set cmd save
case --clear case --clear
set cmd clear set cmd clear
case --search case --search
set cmd print set cmd print
end end
end end
else
#Execute history builtin without any argument
builtin history
return
end end
switch $cmd switch $cmd
@@ -99,18 +104,16 @@ function history --description "Deletes an item from history"
end end
end end
end end
case save
#Save changes to history file
builtin history $argv
case clear case clear
# Erase the entire history # Erase the entire history
if test $clear = 1 echo "Are you sure you want to clear history ? (y/n)"
echo "Are you sure you want to clear history ? (y/n)" read ch
read ch if test $ch = "y"
if test $ch = "y" builtin history $argv
builtin history $argv echo "History cleared!"
echo "History cleared!" end
end
else
builtin history $argv
end
end end
end end