case insensitive and - for qcd

This commit is contained in:
ville rantanen
2013-09-02 17:24:44 +03:00
parent c142b7f55f
commit 0ca46c6e1f
2 changed files with 23 additions and 13 deletions

6
droopy
View File

@@ -713,12 +713,14 @@ class HTTPUploadHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# -- Save file (numbered to avoid overwriting, ex: foo-3.png)
form = DroopyFieldStorage(fp = self.rfile, environ = env);
fileitem = form[self.form_field]
realname=""
if self.form_realname in form.keys():
realname = form[self.form_realname].value.decode('utf-8')
if realname=="":
filename = self.basename(fileitem.filename).decode('utf-8')
else:
self.log_message("Got realname: %s", realname)
filename=self.basename(realname)
else:
filename = self.basename(fileitem.filename).decode('utf-8')
if filename == "":
self.send_response(303)

View File

@@ -19,8 +19,9 @@ function qcd() {
local OPTIND
local OPTARG
local opt
local case
while getopts aLl:hm opt
while getopts aiLl:hm opt
do case "$opt" in
a)
# Adding
@@ -33,6 +34,9 @@ function qcd() {
echo "$name":$( pwd ) >> ~/.qcd
return
;;
i)
case="-i"
;;
L)
echo ==History ~/.bash_cdhistory:
cat ~/.bash_cdhistory
@@ -42,7 +46,7 @@ function qcd() {
return
;;
l)
local d=$( grep -h ^"$OPTARG" ~/.qcd <( tac ~/.bash_cdhistory ) | head -n 1 )
local d=$( grep $case -h ^"$OPTARG" ~/.qcd <( tac ~/.bash_cdhistory ) | head -n 1 )
d=${d/*:/}
echo $d
return
@@ -64,14 +68,14 @@ function qcd() {
return
;;
h)
echo 'qcd [-mLh]|[-al] [name]
echo 'qcd [-hiLm]|[-al] [name]
Change current working path based on the list ~/.qcd
Keeps a history of folders visited in ~/.bash_cdhistory
-a [name] Adds the path to the list
You may add the name of the path, but when omitted
the basename will be used
-i Case insensitive search, must come first.
-l [name] Show the match, but do not change
-L Lists the paths
-m Maintain the list, deleting non-existing entries'
@@ -79,17 +83,21 @@ Keeps a history of folders visited in ~/.bash_cdhistory
;;
esac
done
shift $(($OPTIND - 1))
unset OPTSTRING
unset OPTIND
if [ -z "$1" ]
then \cd
else
d=$( grep -h ^"$1" ~/.qcd <( tac ~/.bash_cdhistory ) | head -n 1 )
then \cd; return
fi
if [ "$1" = "-" ]
then \cd -; return
fi
d=$( grep $case -h ^"$1" ~/.qcd <( tac ~/.bash_cdhistory ) | head -n 1 )
d=${d/*:/}
if [ ! -z "$d" ]
then \cd "$d"
fi
fi
}