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 () {
31
31
-v shortlink
32
32
-h display this screen
33
33
EOF
34
- exit 0
34
+ exit 0
35
35
}
36
36
37
37
err () {
38
- echo $1
39
- usage
38
+ echo $1
39
+ usage
40
40
}
41
41
42
42
optstest () {
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
64
64
}
65
65
66
66
case $# 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!" ;;
73
73
esac
74
74
75
75
if [ -z " $VANITY " ]
76
76
then
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 `
78
78
else
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
80
87
fi
You can’t perform that action at this time.
0 commit comments