sh portability question

Daniel Jacobowitz drow@mvista.com
Sun Nov 24 09:15:00 GMT 2002


On Sat, Nov 23, 2002 at 05:45:12PM -0500, Nathanael Nerode wrote:
> This change eliminates leftover support for non-autoconfiscated subdirectories.
> But before I test and submit it properly (I anticipate some changes), 
> I want to check that the use of {} is portable.  Can someone who knows more 
> about shellology verify?

I don't believe you even need it.  It reduces to:

rm -f no-such-file skip-this-dir; \
CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
$(BUILD_CONFIGARGS) $${srcdiroption} \  
--with-build-subdir="$(BUILD_SUBDIR)" || exit 1; \

The rm isn't about to fail, thus the -f.

Some judicious use of set -e would make this much less scary...

> 
> --Nathanael
> 
> --- Makefile.tpl	2002-11-23 17:31:50.000000000 -0500
> +++ Makefile.tpl.new	2002-11-23 17:42:29.000000000 -0500
> @@ -864,17 +864,11 @@
>  	      srcdiroption="--srcdir=$${topdir}/[+module+]"; \
>  	      libsrcdir="$$s/[+module+]"; \
>  	    fi; \
> -	    if [ -f $${libsrcdir}/configure ] ; then \
> -	      rm -f no-such-file skip-this-dir; \
> +	    { rm -f no-such-file skip-this-dir; \
>  	      CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
>  		$(BUILD_CONFIGARGS) $${srcdiroption} \
>  		--with-build-subdir="$(BUILD_SUBDIR)"; \
> -	    else \
> -	      rm -f no-such-file skip-this-dir; \
> -	      CONFIG_SITE=no-such-file $(SHELL) $$s/configure \
> -		$(BUILD_CONFIGARGS) $${srcdiroption} \
> -		--with-build-subdir="$(BUILD_SUBDIR)"; \
> -	    fi || exit 1; \
> +	    } || exit 1; \
>  	    if [ -f skip-this-dir ] ; then \
>  	      sh skip-this-dir; \
>  	      rm -f skip-this-dir; \
> @@ -1029,17 +1023,11 @@
>  	      srcdiroption="--srcdir=$${topdir}/[+module+]"; \
>  	      libsrcdir="$$s/[+module+]"; \
>  	    fi; \
> -	    if [ -f $${libsrcdir}/configure ] ; then \
> -	      rm -f no-such-file skip-this-dir; \
> +	    { rm -f no-such-file skip-this-dir; \
>  	      CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
>  		$(TARGET_CONFIGARGS) $${srcdiroption} \
>  		--with-target-subdir="$(TARGET_SUBDIR)"; \
> -	    else \
> -	      rm -f no-such-file skip-this-dir; \
> -	      CONFIG_SITE=no-such-file $(SHELL) $$s/configure \
> -		$(TARGET_CONFIGARGS) $${srcdiroption} \
> -		--with-target-subdir="$(TARGET_SUBDIR)"; \
> -	    fi || exit 1; \
> +	    } || exit 1; \
>  	    if [ -f skip-this-dir ] ; then \
>  	      sh skip-this-dir; \
>  	      rm -f skip-this-dir; \
> 

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



More information about the Gcc-patches mailing list