libtool-patches
[Top][All Lists]
Advanced

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

Re: small abstractions: func_source,func_execute_cmds


From: Eric Blake
Subject: Re: small abstractions: func_source,func_execute_cmds
Date: Wed, 10 Aug 2005 14:47:05 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de> writes:

> +# func_source file noexe
> +# Source FILE, adding directory component if necessary.
> +# If noexe is given, add a dot to prevent `$file.exe' from
> +# being sourced on system with automatic-append-.exe behavior.
> +func_source ()
> +{
> +    $opt_debug
> +    case $2,$build in
> +    noexe,*cygwin* | noexe,*mingw*)
> +       func_source_file=$1. ;;
> +    *) func_source_file=$1  ;;

This is wrong for cygwin.  For starters, cygwin does not auto-append .exe when 
sourcing a file, but correctly sources the filename as it was spelled.  (.exe 
is auto-appended when exec()ing an executable, but sourcing is different from 
exec()ing.)

$ echo echo plain > bar
$ echo echo exe > bar.exe
$ . bar
plain
$ . bar.
plain
$ . bar.exe
exe
$ echo echo only > only.exe
$ . only
bash: ./only: No such file or directory

Furthermore, appending a trailing . does not always work in cygwin.  Cygwin has 
the concept of managed mounts (where case distinctions are legal, and all 
characters and spellings normally forbidden by Windows are made possible by 
managed name munging under the hood; the only exceptions are that \ is still a 
dirsep instead of a filename character, and that a filename like a: is still 
absolute so you need ./a: instead).  On a managed mount, trailing . is not 
stripped, so adding a trailing dot with the excuse of suppressing .exe magic 
breaks:

$ cd managed/
/home/eblake/managed
$ echo echo plain > bar
$ . bar
plain
$ . bar.
bash: bar.: No such file or directory


> +    esac
> +    case $func_source_file in
> +    */* | *\\*)      . "$func_source_file" ;;
> +    *)               . "./$func_source_file" ;;
> +    esac
> +}
> +
> +
...
> 
> -       # To insure that "foo" is sourced, and not "foo.exe",
> -       # finese the cygwin/MSYS system by explicitly sourcing "foo."
> -       # which disallows the automatic-append-.exe behavior.
> -       case $build in
> -       *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
> -       *) wrapperdot=${wrapper} ;;
> -       esac
> -       # If there is no directory component, then add one.
> -       case $file in
> -       */* | *\\*) . ${wrapperdot} ;;
> -       *) . ./${wrapperdot} ;;
> -       esac
> +       func_source "$wrapper" noexe

OK, so your refactoring did not introduce the bug; it was already present.  But 
it still needs to be fixed.

--
Eric Blake







reply via email to

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