[Pkg-privacy-commits] [torsocks] 01/01: Display correct error message when the wrapped program cannot be found in $PATH.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:09:15 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch bugfix/non-existent-wrapped-program
in repository torsocks.

commit 2a07551d4f9b29b2c3962f6cf7ffd5b6768b20fa
Author: intrigeri <intrigeri at boum.org>
Date:   Mon Jan 30 17:55:42 2012 +0100

    Display correct error message when the wrapped program cannot be found in $PATH.
---
 src/torsocks.in   | 9 ++++++++-
 src/usewithtor.in | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/torsocks.in b/src/torsocks.in
index 53db2fc..678f854 100755
--- a/src/torsocks.in
+++ b/src/torsocks.in
@@ -63,6 +63,11 @@
 # Tamas Szerb <toma at rulez.org>
 # Modified by Robert Hogan <robert at roberthogan.net> April 16th 2006
 
+not_found () {
+    echo "ERROR: $1 cannot be found in PATH." >&2
+    exit 1
+}
+
 set_id () {
     echo "ERROR: $1 is set${2}id. torsocks will not work on a set${2}id executable." >&2
     exit 1
@@ -133,7 +138,9 @@ case "$1" in
 
     if [ $# -gt 0 ]
     then
-      if [ -u `which "$1"` ]; then
+      if ! which "$1" >/dev/null 2>&1; then
+          not_found $1
+      elif [ -u `which "$1"` ]; then
           set_id $1 u
       elif [ -g `which "$1"` ]; then
           set_id $1 g
diff --git a/src/usewithtor.in b/src/usewithtor.in
index 0a1e42d..e606760 100644
--- a/src/usewithtor.in
+++ b/src/usewithtor.in
@@ -42,6 +42,11 @@ usage () {
 	echo "Usage: $0 [-hv] <command> [<options>...]"
 }
 
+not_found () {
+	echo "ERROR: $1 cannot be found in PATH." >&2
+	exit 1
+}
+
 set_id () {
 	echo "ERROR: $1 is set${2}id. usewithtor will not work on a set${2}id executable." >&2
 	exit 1
@@ -68,7 +73,9 @@ while [ "$1" ]; do
 	esac
 done
 
-if [ -u `which "$1"` ]; then
+if ! which "$1" >/dev/null 2>&1; then
+	not_found $1
+elif [ -u `which "$1"` ]; then
 	set_id $1 u
 elif [ -g `which "$1"` ]; then
 	set_id $1 g

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/torsocks.git



More information about the Pkg-privacy-commits mailing list