bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: feature request: file_not_found_handle()


From: Chet Ramey
Subject: Re: feature request: file_not_found_handle()
Date: Mon, 19 Aug 2013 15:39:41 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

On 8/19/13 6:57 AM, Andreas Gregor Frank wrote:
> Hi Chet,
> 
> I have no idea if there is "enough" demand, but i think there will be some
> ideas to use this feature...
> I still think it is a question of consistency to be able to handle a "No
> such file or directory event", if i can do this with a "command not found
> event" (independent of the command_not_found_handle history).
> 
> You say you can easily test whether or not if the file in the pathname exists.

That is not what I said.  I said that you, the script writer, can check
whether or not a filename containing a slash is executable before
attempting to execute it.  Maybe a function something like this (untested):

ckexec()
{
        case "$1" in
        */*)    ;;
        *)      "$@"  ; return $? ;;
        esac

        if [ -x "$1" ]; then
                "$@"
        else
                other-prog "$@"
        fi
}


Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]