Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11700

Substring expansion error when offset contains a colon

Newsgroups gnu.bash.bug
Date 2015-10-19 00:45 -0700
Message-ID <ebef1587-2560-4b8c-b845-ce3d0d39cfda@googlegroups.com> (permalink)
Subject Substring expansion error when offset contains a colon
From grishalevit@gmail.com

Show all headers | View raw


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.

Back to gnu.bash.bug | Previous | NextNext in thread | Find similar


Thread

Substring expansion error when offset contains a colon grishalevit@gmail.com - 2015-10-19 00:45 -0700
  Re: Substring expansion error when offset contains a colon Chet Ramey <chet.ramey@case.edu> - 2015-10-26 09:19 -0400

csiph-web