Reputation: 81
I don't kanow what #? mean, I goolged,found nothing
the full file: tinode/chat
goplat=( darwin windows linux )
# Supported CPU architectures: amd64
goarc=( amd64 )
# Supported database tags
dbtags=( mysql mongodb rethinkdb )
for line in $@; do
eval "$line"
done
version=${tag#?}
if [ -z "$version" ]; then
# Get last git tag as release version. Tag looks like 'v.1.2.3', so strip 'v'.
version=`git describe --tags`
version=${version#?}
fi
Upvotes: 0
Views: 1287
Reputation: 263267
${tag#?}
expands to the value of $tag
with the first character deleted.
Quoting the POSIX shell specification:
${parameter#[word]}
Remove Smallest Prefix Pattern. The word shall be expanded to produce a pattern. The parameter expansion shall then result in parameter, with the smallest portion of the prefix matched by the pattern deleted. If present, word shall not begin with an unquoted'#'
.
In this case the pattern is ?
, which matches a single character.
If you're using bash, the Bash manual also covers this (you can view the manual on your system with info bash
):
'${PARAMETER#WORD}'
'${PARAMETER##WORD}'
The WORD is expanded to produce a pattern just as in filename
expansion (*note Filename Expansion::). If the pattern matches the
beginning of the expanded value of PARAMETER, then the result of
the expansion is the expanded value of PARAMETER with the shortest
matching pattern (the '#' case) or the longest matching pattern
(the '##' case) deleted. If PARAMETER is '@' or '*', the pattern
removal operation is applied to each positional parameter in turn,
and the expansion is the resultant list. If PARAMETER is an array
variable subscripted with '@' or '*', the pattern removal operation
is applied to each member of the array in turn, and the expansion
is the resultant list.
Upvotes: 4
Reputation: 81
#!/bin/bash
tag='123'
version=${tag#?}
echo ${version} # output is: 23
=======
so #? is remove first character?
Upvotes: -2