bash selective filename expansion to pass to daemon -
i want define function or alias starts process daemon can still grok filenames passed it. think:
function emacs() { daemon /usr/bin/emacs $* }
this should work for
emacs localfile.txt /tmp/anotherfile.txt
i need function changes localfile.txt $pwd/localfile.txt , not /tmp/anotherfile.txt. there bash-elegant way this? advice appreciated. if not, thinking of writing in perl.
/iaw
first, if weren't changing arguments, you'd want use "$@"
, not $*
. otherwise spaces cause argument list re-split.
but sure. try this.
function emacs() { local args=() in "$@"; case "$a" in [/-]*) args+=("$a");; # pass options , absolute filenames as-is *) args+=("$pwd/$a");; # absolutify else esac done daemon "$(type -p emacs)" "${args[@]}" }
this still breaks option arguments aren't files, it's start.
however, assumes emacs
works daemon, doesn't due lack of controlling terminal. i'm guessing actual application not text editor.. or 1 maintains own window, or something.
Comments
Post a Comment