Guido Berhoerster wrote:
* Stefan Seyfried
[2013-03-30 16:57]: Am 30.03.2013 16:44, schrieb Guido Berhoerster:
type -p is what you want. No, it isn't, you want "command -v". In contrast to the "type" bashism, it is specified by POSIX, implemented as a regular builtin in all Bourne-derived shells present in Factory, and
* Andreas Schwab
[2013-03-30 16:24]: perfectly capable of covering the most common use-case of "which", namely printing the pathname of the given utility while taking PATH into account. But both are not equivalent to "which": seife@susi:~> which ls /usr/bin/ls seife@susi:~> type -p ls seife@susi:~> command -v ls alias ls='ls $LS_OPTIONS'
That is no relevant for script use since there are no aliases in a non-interactive shell.
Unless a caller turned them on: shopt While most of my shopts are only for interactive shells, expand_aliases is too useful in programming in bash to let go. So I have: shopt -s expand_aliases if [ -n "$_sh_interactive_shell" ] ; then if [[ "$BASH_VERSINFO" == '4' ]]; then shopt -s globstar dirspell autocd fi set -o pipefail shopt -s nocaseglob nocasematch expand_aliases shopt -s cdable_vars cdspell checkhash checkwinsize cmdhist dotglob extglob shopt -s histappend histverify hostcomplete lithist histreedit shopt -s no_empty_cmd_completion xpg_echo called from my bashrc, and bash_env I define aliases for keywords like: alias int='declare -i'
int i=1 i+=2 #note, if you don't dcl i an int first, you get string concatenation echo $i 3
comand -v with a function will just give the funcname, not the path there is no way to list the path using the POSIX util. POSIX is lowest common denominator. Back in the 11.x timeframe, you could safely delete a directory contents but not the directory by (cd <dir> && rm -fr --one-filesystem .) There is no other easy expression of that idiom. So POSIX removed it, on the grounds that BSD had it in to protect their students from accidently deleting all files on similar reasoning to the default disabling of rm -fr /. But they are very different. if you try it with the name, depending on the version of coreutils you run, different syntaxes operate differently if the directory name is a symlink. wild cards are out as they can start on start on a submount and delete it too and bash's ** expansion doesn't have an option to stay on 1 file system. You'd have to use 'find' to reconstruct the same behavior they removed to protect the children. rm has to do a depth first traversal when doing a delete, but has a special exception added to inspect the top directory first and if it ".", then abort the normal traveral (with -f suppressing any error messages about not being able to delete ".". Don't suppse suse would want a patch fixing that....so it's useful again... I happen to have one available for some reason or another... -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org