b1onic
b1onic

Reputation: 239

Error when passing argument to a command in a bash script

I would like to execute a command like this:

#!/bin/sh
`which rvmsudo` `which program` argument

but I get this issue

/usr/bin/env: argument: No such file or directory

Upvotes: 0

Views: 121

Answers (1)

Eugen Rieck
Eugen Rieck

Reputation: 65332

Make sure, all of the which statements return valid:

#!/bin/bash

RVMSUDO=`which rvmsudo`
test -z "$RCMSUDO" && exit 1

PROGRAM=`which program`
test -z "$PROGRAM" && exit 2

$RVMSUDO $PROGRAM argument

Upvotes: 2

Related Questions