[PATCH 11/12] hush: only remove backslashes introduced from glob

Sascha Hauer s.hauer at pengutronix.de
Mon Mar 29 06:00:58 EDT 2010


On Mon, Mar 29, 2010 at 11:36:22AM +0200, Sascha Hauer wrote:
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
>  common/hush.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/common/hush.c b/common/hush.c
> index 6a8b56b..afa67d1 100644
> --- a/common/hush.c
> +++ b/common/hush.c
> @@ -779,8 +779,9 @@ static int globhack(const char *src, int flags, glob_t *pglob)
>  	int cnt=0, pathc;
>  	const char *s;
>  	char *dest;
> +
>  	for (cnt=1, s=src; s && *s; s++) {
> -		if (*s == '\\') s++;
> +		if (*s == '\\' && strchr("*[?", *(s + 1))) s++;
>  		cnt++;
>  	}
>  	dest = xmalloc(cnt);
> @@ -794,7 +795,7 @@ static int globhack(const char *src, int flags, glob_t *pglob)
>  	pglob->gl_pathv[pathc-1] = dest;
>  	pglob->gl_pathv[pathc] = NULL;
>  	for (s=src; s && *s; s++, dest++) {
> -		if (*s == '\\') s++;
> +		if (*s == '\\' && strchr("*[?", *(s + 1))) s++;
>  		*dest = *s;
>  	}
>  	*dest='\0';


This patch also fixes a quoting workaround found in many
/env/bin/_update scripts:

if [ \! -e "$part" ]; then
        echo "Partition $part does not exist"
        exit 1
fi

The backslash is not needed anymore (and in fact now breaks the script)

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list