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

Re: [RFC] Remove massbuild bashisms



On Tue, Aug 28, 2007 at 05:24:48PM +0200, Jérémy Bobbio wrote:
> +	BDEP_SOURCE_PREFIX=$(echo "$BDEP_SOURCE" | head -c 1)

My recommendation was wrong -- I left out a step.  Try this:

_TMP=${BDEP_SOURCE#?} # everything but the first character
BDEP_SOURCE_PREFIX=${BDEP_SOURCE%$_TMP}

The first expansion gets matches our "suffix", and the second removes that
suffix.

Niftily, this works right (for your purposes) even if $_TMP ends up
containing glob characters.  They'll be treated literally, and not screw up
your pattern.  To stuff a glob pattern to be used as such inside a variable
for use in a later parameter expansion would probably require a clever eval
trick.

Sorry for leading you astray with my first response.

-- 
G. Branden Robinson                |     Never attribute to conspiracy that
Debian GNU/Linux                   |     which can be adequately explained
branden@debian.org                 |     by economics.
http://people.debian.org/~branden/ |

Attachment: signature.asc
Description: Digital signature


Reply to: