vim/runtime/syntax/testdir/input/sh_03.sh
Bram Moolenaar 1aa5f1c21f patch 9.0.1647: insufficient testing for syntax plugins
Problem:    Insufficient testing for syntax plugins.
Solution:   Add shell file examples. (Charles Campbell)  Create a messages
            file for easier debugging and reporting the test results.
2023-06-22 21:57:51 +01:00

33 lines
971 B
Bash

#!/bin/ksh
# Test variable modifiers
# Variable=value
Variable='value'
Variable="value"
VariableA="pat1xxpat2"
VariableB="pat2xxpat1"
echo ${#}
echo ${#VariableA}
echo ${VariableA#pat1}
echo ${VariableA##pat1}
echo ${VariableB%pat1}
echo ${VariableB%%pat1}
# This gets marked as an error
Variable=${VariableB:+${VariableC:=eng}} # :+ seems to work for ksh as well as bash
Variable=${VariableB:-${VariableC:-eng}} # :- is ksh and bash
# This is OK
Variable='${VariableB:+${VariableC:=eng}}'
Variable='${VariableB:-${VariableC:-eng}}'
Variable="${VariableB:+${VariableC:=eng}}" # :+ seems to work for ksh as well as bash
Variable="${VariableB:-${VariableC:-eng}}" # :- is ksh and bash
# These are OK
: ${VariableB:-${VariableC:-eng}}
: "${VariableB:-${VariableC:-eng}}"
: '${VariableB:-${VariableC:-eng}}'
# Another test
Variable=${VariableB:-${VariableC:-${VariableD:-${VariableE:=eng}}}}
: ${VariableB:=${VariableC:-${VariableD:-${VariableE:=eng}}}}