bug-bash
[Top][All Lists]
Advanced

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

Substring expansion error when offset contains a colon


From: grishalevit
Subject: Substring expansion error when offset contains a colon
Date: Mon, 19 Oct 2015 00:45:42 -0700 (PDT)
User-agent: G2/1.0

When using ${parameter:offset:length} expansion, the parser doesn't account for 
all the ways that a colon can appear in "offset".

For example:

$ echo ${PARAM:${OFFSET:-0}}
-bash: ${OFFSET: bad substitution

or:

# declare -A A=([a:b]=0)
# echo ${PARAM:${A[a:b]}}
-bash: ${A[a: bad substitution

It seems that the issue is in the use of skiparith in verify_substring_values.  
Switching to to skip_to_delim removes this issue.  The 
${parameter/pattern/string} expansion uses skip_to_delim to search for the 
second '/' so I suspect it's use is appropriate here as well.


reply via email to

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