File tree Expand file tree Collapse file tree 1 file changed +39
-32
lines changed Expand file tree Collapse file tree 1 file changed +39
-32
lines changed Original file line number Diff line number Diff line change @@ -31,50 +31,57 @@ usage () {
3131 -v shortlink
3232 -h display this screen
3333EOF
34- exit 0
34+ exit 0
3535}
3636
3737err () {
38- echo $1
39- usage
38+ echo $1
39+ usage
4040}
4141
4242optstest () {
43- found=0
44- for arg in " $@ "
45- do
46- if echo $arg | cut -d/ -f3 | grep -q " github.com\|raw.githubusercontent.com"
47- then
48- GHURL=$arg
49- found=1
50- elif [ $arg = " -h" ]
51- then
52- usage
53- elif [ $arg = " -v" ]
54- then
55- :
56- else
57- VANITY=$arg
58- fi
59- done
60- if [ $found = 0 ]
61- then
62- err " must be a valid github.com url!"
63- fi
43+ found=0
44+ for arg in " $@ "
45+ do
46+ if echo $arg | cut -d/ -f3 | grep -q " github.com\|raw.githubusercontent.com"
47+ then
48+ GHURL=$arg
49+ found=1
50+ elif [ $arg = " -h" ]
51+ then
52+ usage
53+ elif [ $arg = " -v" ]
54+ then
55+ :
56+ else
57+ VANITY=$arg
58+ fi
59+ done
60+ if [ $found = 0 ]
61+ then
62+ err " must be a valid github.com url!"
63+ fi
6464}
6565
6666case $# in
67- 1)
68- optstest $1 ;;
69- 3)
70- optstest $1 $2 $3 ;;
71- * )
72- err " invalid number of arguments!" ;;
67+ 1)
68+ optstest $1 ;;
69+ 3)
70+ optstest $1 $2 $3 ;;
71+ * )
72+ err " invalid number of arguments!" ;;
7373esac
7474
7575if [ -z " $VANITY " ]
7676then
77- curl -i http://git.io -F " url=$GHURL "
77+ url= ` curl -is http://git.io -F " url=$GHURL " | grep -i " location " | cut -d ' ' -f2 `
7878else
79- curl -i http://git.io -F " url=$GHURL " -F " code=$VANITY "
79+ url=` curl -is http://git.io -F " url=$GHURL " -F " code=$VANITY " | grep -i " location" | cut -d' ' -f2`
80+ fi
81+
82+ if [ -z $url ]
83+ then
84+ err " must be a valid github.com url!"
85+ else
86+ echo $url
8087fi
You can’t perform that action at this time.
0 commit comments