From 55ef8f6fccf1addf5c48161b6a4cc9ba507cb71f Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Mon, 4 Dec 2017 00:51:27 -0800 Subject: [PATCH] allow execution of files not in path Previously, if the file you wanted to nvidia-xrun was not in your path and/or there were spaces in the filename, nvidia-xrun would fail. --- nvidia-xinitrc | 2 +- nvidia-xrun | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/nvidia-xinitrc b/nvidia-xinitrc index b4f733c..bf3e2ac 100644 --- a/nvidia-xinitrc +++ b/nvidia-xinitrc @@ -39,6 +39,6 @@ if [ -f "$userxinitrc" ]; then sh ${userxinitrc} $# else if [ $# -gt 0 ]; then - $* + "$*" fi fi diff --git a/nvidia-xrun b/nvidia-xrun index 3a5c54c..23189f0 100644 --- a/nvidia-xrun +++ b/nvidia-xrun @@ -45,14 +45,20 @@ NEWDISP=":$XNUM" if [ ! -z "$*" ] # generate exec line if arguments are given then - # test if executable exists - if [ ! -x "$(which $1 2> /dev/null)" ] + # test if executable exists in path + if [ -x "$(which $1 2> /dev/null)" ] then + # generate exec line + EXECL="$(which $1)" + # test if executable exists on disk + elif [ -e "$(realpath "$1")" ] + then + # generate exec line + EXECL="$(realpath "$1")" + else echo "$1: No such executable!" exit 1 fi - # generate exec line - EXECL="$(which $1)" shift 1 EXECL="$EXECL $*" else # prepare to start new X sessions if no arguments passed