You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
notepad-plus-plus/lexilla/test/examples/bash/Nested.bsh

82 lines
1.1 KiB

# Nested elements and other complex cases
# String with backtick inclusion
"x`ls`"
# Nested string
"x`ls "*.c"`"
# Not terminated at first "
"x`ls" # "`" #
# String with command inclusion
"x$(ls)"
# Nested command
$(ls -la$(ls *.c))
# Check strings and backticks in command
echo $('ls' "." `ls` $'.' $".")
# $( not terminated by ) if contains unterminated string
$('x) # ') #
$("x) # ") #
$(`x) # `) # Bash doesn't like this
$($'x) # ') #
$($"x) # ") #
# Parameter expansion
var=abcdef
sub=abc
rep='& '
echo ${var/$sub/"${rep}}"} #
# issue 216
option="no[foo]"
option=${option%%[<{().[]*}
echo $option
# '$' in variable
echo $$PID
echo $var${var}
# Here-doc with internal elements
cat <<EOF
$scalar
${var}
$((1+2))
$(pwd)
`pwd`
EOF
# Quoted delimiter treats here-doc as simple string
cat <<"EOF"
$scalar
${var}
$((1+2))
$(pwd)
`pwd`
EOF
# Escaped same as quoted
cat <<\EOF
$scalar
EOF
# Nesting
echo "$((1 + 2))" #
echo "$[1 + 2]" #
# Multiple nesting levels
$(ls -la$(ls $(c) $'*.c' ` $(${s})`))
# Multi-line
$(ls |
more)
$(
`x`
"x"
`ls`
$'x'
$"x"
)
#end -- checks termination of previous