Use `test -z' where possible.
authorBenoit Sigoure <[email protected]>
Tue, 6 Nov 2007 19:30:09 +0000 (6 20:30 +0100)
committerBenoit Sigoure <[email protected]>
Tue, 6 Nov 2007 19:30:09 +0000 (6 20:30 +0100)
Signed-off-by: Benoit Sigoure <[email protected]>
svn-wrapper.sh

index fa0e883..0d13c5a 100755 (executable)
@@ -251,7 +251,7 @@ ensure_not_empty()
       return;;
   esac
   ene_val=`echo "$2" | tr -d ' \t\n'`
-  test x"$ene_val" = x && abort "$1: empty value"
+  test -z "$ene_val" && abort "$1: empty value"
 }
 
 # find_prog prog-name
@@ -264,7 +264,7 @@ find_prog()
   IFS=$PATH_SEPARATOR
   for dir in $PATH; do
     IFS=$save_IFS
-    test x"$dir" = x && continue
+    test -z "$dir" && continue
     # The basic test for an executable is `test -f $f && test -x $f'.
     # (`test -x' is not enough, because it can also be true for directories.)
     # We have to try this both for $1 and $1.exe.
@@ -357,8 +357,8 @@ require_mail()
 my_sendmail()
 {
   test -f "$1" || abort "my_sendmail: Cannot find the mail file: $1"
-  test x"$2" = x && warn 'my_sendmail: Empty subject.'
-  test x"$3" = x && abort 'my_sendmail: No recipient specified.'
+  test -z "$2" && warn 'my_sendmail: Empty subject.'
+  test -z "$3" && abort 'my_sendmail: No recipient specified.'
 
   content_type='Content-type: text/plain'
   extra_headers="X-Mailer: svn-wrapper v$version (g$revision)
@@ -495,7 +495,7 @@ selfupdate()
   my_ver=$revision
   tmp_ver=`sed '/^# $Id[:].*$/!d;
                 s/.*$Id[:] *\([a-f0-9]\{6\}\).*/\1/' "$tmp_me"`
-  test x"$tmp_ver" = x && abort "Cannot find the revision of $tmp_me"
+  test -z "$tmp_ver" && abort "Cannot find the revision of $tmp_me"
   if [ x"$my_ver" != x"$tmp_ver" ]; then # There IS an update...
     echo "An update is available, r$tmp_ver (your version is r$my_ver)"
 
@@ -531,7 +531,7 @@ get_svn_diff_and_diffstat()
   else
     # Ignore white spaces. Can't svn diff -x -w: svn 1.4 only.
     svn_diff=`svn_diffw "$@"`
-    test x"$svn_diff" = x && svn_diff=`$SVN diff "$@"`
+    test -z "$svn_diff" && svn_diff=`$SVN diff "$@"`
     if require_diffstat; then
       svn_diff_stat=`echo "$svn_diff" | diffstat`
     else
@@ -546,7 +546,7 @@ git_get_repos_info_()
 {
   # FIXME: 1st commit: "fatal: bad default revision 'HEAD'" on stderr
   repos_url=`git config --get svn-remote.svn.url`
-  test x"$repos_url" = x && repos_url='(git:unknown)'
+  test -z "$repos_url" && repos_url='(git:unknown)'
   git_branch=`git branch | awk '/^\*/ { print substr($0, 3) }'`
   if [ x"$git_branch" = x'(no branch)' ]; then
     yesno 'You are on a detached HEAD, do you really want to continue?' \
@@ -839,7 +839,7 @@ $changed_externals"
     repos_root=`echo "$svn_info_tmp" | sed '/^Repository Root: /!d;s///'`
     repos_url=`echo "$svn_info_tmp" | sed '/^URL: /!d;s///'`
     # It looks like svn <1.3 didn't display a "Repository Root" entry.
-    test x"$repos_root" = x && repos_root=$repos_url
+    test -z "$repos_root" && repos_root=$repos_url
   fi
 
   cd "$here"
@@ -973,9 +973,9 @@ If this is a real git repository, do this:
 
     get_mailto_property
 
-    test x"$FULLNAME" = x && FULLNAME='Type Your Name Here' \
+    test -z "$FULLNAME" && FULLNAME='Type Your Name Here' \
     && warn_env FULLNAME
-    test x"$EMAIL" = x && EMAIL='[email protected]' && warn_env EMAIL
+    test -z "$EMAIL" && EMAIL='[email protected]' && warn_env EMAIL
 
     if $git_mode; then
       if $git_commit_all; then
@@ -1042,7 +1042,7 @@ Instructions:
     fi
     r_before_rev=r
     $git_mode && r_before_rev=
-    test x"$extra_repos_info" = x || extra_repos_info="
+    test -z "$extra_repos_info" || extra_repos_info="
   $extra_repos_info"
     echo "\
 --You must fill this file correctly to continue--           -*- vcs -*-
@@ -1138,8 +1138,8 @@ vi: ft=diff:noet:tw=76:" >>"$tmp_log"
     $send_a_mail && ensure_not_empty '"To:" field of the mail' "$mail_to"
   fi
 
-  test x"$FULLNAME" = x && warn_env FULLNAME && FULLNAME=$USER
-  test x"$EMAIL" = x && warn_env EMAIL && EMAIL=$USER
+  test -z "$FULLNAME" && warn_env FULLNAME && FULLNAME=$USER
+  test -z "$EMAIL" && warn_env EMAIL && EMAIL=$USER
   myself=`echo "$FULLNAME <$EMAIL>" | sed "$sed_escape"`
   mail_from=`echo "$full_log" | sed "/^From: */!d;s///;s@<MYSELF>@$myself@g"`
   ensure_not_empty '"From:" field of the mail' "$mail_from"
@@ -1325,10 +1325,10 @@ $mail_title"
   else
     svn_info_tmp=`$SVN info "$change_log_dir/ChangeLog"`
     REV=`echo "$svn_info_tmp" | sed '/^Revision: /!d;s///'`
-    test x"$REV" = x && REV=`echo "$svn_info_tmp" \
+    test -z "$REV" && REV=`echo "$svn_info_tmp" \
                              | sed '/^Last Changed Rev: /!d;s///'`
   fi
-  test x"$REV" = x && abort 'Cannot detect the current revision.'
+  test -z "$REV" && abort 'Cannot detect the current revision.'
   echo "$REV"
 
   # Let's make sure we have the real diff by asking the ChangeSet we've just
@@ -1449,7 +1449,7 @@ svn_mail()
         REV=`git rev-list --pretty=format:%h 'HEAD^' --max-count=1 | sed '1d;q'`
       else
         REV=`svn_revision || abort 'Cannot get current revision number'`
-        test x"$REV" = x && abort 'Cannot get current revision number'
+        test -z "$REV" && abort 'Cannot get current revision number'
         if [ "$REV" -lt 1 ]; then
           abort 'No previous revision.'
         fi
@@ -1458,7 +1458,7 @@ svn_mail()
       ;;
     HEAD)
       REV=`svn_revision || abort 'Cannot get current revision number'`
-      test x"$REV" = x && abort 'Cannot get current revision number'
+      test -z "$REV" && abort 'Cannot get current revision number'
       ;;
     *) REV=$1;;
   esac
@@ -1516,9 +1516,9 @@ Subject: $subject
     to=`echo "$*" | sed 's/  */, /g'`
   fi
 
-  test x"$to" = x && abort 'Cannot find the list of recipients.
+  test -z "$to" && abort 'Cannot find the list of recipients.
                             Please report this bug.'
-  test x"$subject" = x && abort 'Cannot find the subject of the mail.
+  test -z "$subject" && abort 'Cannot find the subject of the mail.
                                  Please report this bug.'
 
   if yesno "Re-sending the mail of r$REV
@@ -1536,7 +1536,7 @@ Are you sure?"; then :; else
     repos_root=`echo "$svn_info_tmp" | sed '/^Repository Root: /!d;s///'`
     repos_url=`echo "$svn_info_tmp" | sed '/^URL: /!d;s///'`
     # It looks like svn <1.3 didn't display a "Repository Root" entry.
-    test x"$repos_root" = x && repos_root=$repos_url
+    test -z "$repos_root" && repos_root=$repos_url
   fi
 
   my_sendmail "$mail_file" "$subject" "$to" \
@@ -1559,7 +1559,7 @@ has_prop()
   hp_plist=`$SVN proplist "$2"`
   test $? -ne 0 && return 2
   hp_res=`echo "$hp_plist" | sed "/^ *$1\$/!d"`
-  test x"$hp_res" = x && return 1
+  test -z "$hp_res" && return 1
   return 0
 }
 
@@ -1577,7 +1577,7 @@ svn_propadd()
             try `svn help propadd` for more info'
 
   path=$3
-  test x"$path" = x && path='.' && set dummy "$@" '.' && shift
+  test -z "$path" && path='.' && set dummy "$@" '.' && shift
   has_prop "$1" "$3" || {
     test $? -eq 2 && return 1 # svn error
     # no property found:
@@ -1612,7 +1612,7 @@ svn_propsed()
             try `svn help propsed` for more info'
 
   path=$3
-  test x"$path" = x && path='.'
+  test -z "$path" && path='.'
   has_prop "$1" "$3" || {
     test $? -eq 2 && return 1 # svn error
     # no property found:
@@ -1850,7 +1850,7 @@ svn_status()
   fi
   svn_status_out=`$SVN status "$@"`
   svn_status_rv=$?
-  test x"$svn_status_out" = x && return $svn_status_rv
+  test -z "$svn_status_out" && return $svn_status_rv
   echo "$svn_status_out" | sed "$sed_svn_st_color"
   return $svn_status_rv
 }