Its better practise to use [[ and ]] rather than [ and ]

This commit is contained in:
Simon Gomizelj 2011-11-28 17:06:13 -05:00
commit c5404482a5

View file

@ -11,7 +11,7 @@
# if [[ ${_plugin__path} == "on" ]]; then # if [[ ${_plugin__path} == "on" ]]; then
# Plugin setting: Add this plugin directory to the path # Plugin setting: Add this plugin directory to the path
# export PATH=$PATH:$ZSH/plugins/sprunge # export PATH=$PATH:$ZSH/plugins/sprunge
# elif [ -z "${commands[sprunge]}" ]; then # elif [[ -z "${commands[sprunge]}" ]]; then
# Nope. No `sprunge` command, period. So, dumb/simple alias, here we go! # Nope. No `sprunge` command, period. So, dumb/simple alias, here we go!
# alias sprunge="curl -F 'sprunge=<-' http://sprunge.us/" # alias sprunge="curl -F 'sprunge=<-' http://sprunge.us/"
# fi # fi
@ -21,9 +21,9 @@
# Original found at http://www.shellperson.net/sprunge-pastebin-script/ # Original found at http://www.shellperson.net/sprunge-pastebin-script/
sprunge () { sprunge () {
if [ -t 0 ]; then if [[ -t 0 ]]; then
if [ "$*" ]; then if [[ "$*" ]]; then
if [ -f "$*" ]; then if [[ -f "$*" ]]; then
# Use python to attempt to detect the syntax # Use python to attempt to detect the syntax
syntax=$(echo "try: syntax=$(echo "try:
from pygments.lexers import get_lexer_for_filename from pygments.lexers import get_lexer_for_filename
@ -81,7 +81,7 @@ HERE
done | curl -F 'sprunge=<-' http://sprunge.us) done | curl -F 'sprunge=<-' http://sprunge.us)
fi fi
if [ "$syntax" != "text" ]; then if [[ "$syntax" != "text" ]]; then
echo "$url?$syntax" echo "$url?$syntax"
else else
echo $url echo $url