Merge pull request #94 from de-vri-es/rosrun-spaces
rosrun: Allow spaces in command names and search paths.
This commit is contained in:
commit
01a5354a97
|
@ -16,13 +16,13 @@ function debug() {
|
||||||
|
|
||||||
while [ $args == 1 ]
|
while [ $args == 1 ]
|
||||||
do
|
do
|
||||||
case $1 in
|
case "$1" in
|
||||||
"--help" | "-h")
|
"--help" | "-h")
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--prefix" | "-p")
|
"--prefix" | "-p")
|
||||||
rosrun_prefix=$2
|
rosrun_prefix="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
@ -48,12 +48,14 @@ case $2 in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ -n $CMAKE_PREFIX_PATH ]]; then
|
if [[ -n $CMAKE_PREFIX_PATH ]]; then
|
||||||
catkin_package_libexec_dir=`catkin_find --without-underlays --libexec --share $1 2> /dev/null`
|
IFS=$'\n'
|
||||||
debug "Looking in catkin libexec dir: $catkin_package_libexec_dir"
|
catkin_package_libexec_dirs=(`catkin_find --without-underlays --libexec --share "$1" 2> /dev/null`)
|
||||||
|
unset IFS
|
||||||
|
debug "Looking in catkin libexec dirs: $catkin_package_libexec_dirs"
|
||||||
fi
|
fi
|
||||||
pkgdir=`rospack find $1`
|
pkgdir=`rospack find "$1"`
|
||||||
debug "Looking in rospack dir: $pkgdir"
|
debug "Looking in rospack dir: $pkgdir"
|
||||||
if [[ -z $catkin_package_libexec_dir && -z $pkgdir ]]; then
|
if [[ ${#catkin_package_libexec_dirs[@]} -eq 0 && -z $pkgdir ]]; then
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
if [[ ! $2 == */* ]]; then
|
if [[ ! $2 == */* ]]; then
|
||||||
|
@ -66,15 +68,18 @@ if [[ ! $2 == */* ]]; then
|
||||||
_perm="/111"
|
_perm="/111"
|
||||||
fi
|
fi
|
||||||
debug "Searching for $2 with permissions $_perm"
|
debug "Searching for $2 with permissions $_perm"
|
||||||
exepathlist=(`find -L $catkin_package_libexec_dir $pkgdir -name $2 -type f -perm $_perm ! -regex ".*$pkgdir\/build\/.*" | uniq`)
|
exepathlist="`find -L "${catkin_package_libexec_dirs[@]}" "$pkgdir" -name "$2" -type f -perm "$_perm" ! -regex ".*$pkgdir\/build\/.*" | uniq`"
|
||||||
|
IFS=$'\n'
|
||||||
|
exepathlist=($exepathlist)
|
||||||
|
unset IFS
|
||||||
unset _perm
|
unset _perm
|
||||||
if [[ ${#exepathlist[@]} == 0 ]]; then
|
if [[ ${#exepathlist[@]} == 0 ]]; then
|
||||||
echo "[rosrun] Couldn't find executable named $2 below $pkgdir"
|
echo "[rosrun] Couldn't find executable named $2 below $pkgdir"
|
||||||
nonexepathlist=(`find -H $pkgdir -name $2`)
|
nonexepathlist=(`find -H "$pkgdir" -name "$2"`)
|
||||||
if [[ ${#nonexepathlist[@]} != 0 ]]; then
|
if [[ ${#nonexepathlist[@]} != 0 ]]; then
|
||||||
echo "[rosrun] Found the following, but they're either not files,"
|
echo "[rosrun] Found the following, but they're either not files,"
|
||||||
echo "[rosrun] or not executable:"
|
echo "[rosrun] or not executable:"
|
||||||
for p in ${nonexepathlist[@]}; do
|
for p in "${nonexepathlist[@]}"; do
|
||||||
echo "[rosrun] ${p}"
|
echo "[rosrun] ${p}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -82,23 +87,23 @@ if [[ ! $2 == */* ]]; then
|
||||||
|
|
||||||
elif [[ ${#exepathlist[@]} -gt 1 ]]; then
|
elif [[ ${#exepathlist[@]} -gt 1 ]]; then
|
||||||
echo "[rosrun] You have chosen a non-unique executable, please pick one of the following:"
|
echo "[rosrun] You have chosen a non-unique executable, please pick one of the following:"
|
||||||
select opt in ${exepathlist[@]}; do
|
select opt in "${exepathlist[@]}"; do
|
||||||
exepath=$opt
|
exepath="$opt"
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
exepath=${exepathlist[0]}
|
exepath="${exepathlist[0]}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
absname=$pkgdir/$2
|
absname="$pkgdir/$2"
|
||||||
debug "Path given. Looing for $absname"
|
debug "Path given. Looing for $absname"
|
||||||
if [ ! -f $absname -o ! -x $absname ]; then
|
if [[ ! -f $absname || ! -x $absname ]]; then
|
||||||
echo "[rosrun] Couldn't find executable named $absname"
|
echo "[rosrun] Couldn't find executable named $absname"
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
exepath=$absname
|
exepath="$absname"
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
debug "Running $rosrun_prefix $exepath" "$@"
|
debug "Running $rosrun_prefix $exepath" "$@"
|
||||||
exec $rosrun_prefix $exepath "$@"
|
exec $rosrun_prefix "$exepath" "$@"
|
||||||
|
|
Loading…
Reference in New Issue