b73d3a4c2725da651efb408a2d78b9faabe7719c — Simon Ser a month ago 46a4cb4
shell/task/word: add parameter plus op
2 files changed, 10 insertions(+), 0 deletions(-)

M shell/task/word.c
M test/word.sh
M shell/task/word.c => shell/task/word.c +8 -0
@@ 162,8 162,16 @@ }
  		return 0;
  	case MRSH_PARAM_EQUAL: // Assign Default Values
+ 		assert(false); // TODO
  	case MRSH_PARAM_QMARK: // Indicate Error if Null or Unset
+ 		assert(false); // TODO
  	case MRSH_PARAM_PLUS: // Use Alternative Value
+ 		if (str == NULL || (str[0] == '\0' && wp->colon)) {
+ 			*result_str = strdup("");
+ 		} else {
+ 			assign_word_or_null(wp->arg, result_str, result_word);
+ 		}
+ 		return 0;
  	case MRSH_PARAM_LEADING_HASH: // String Length
  	case MRSH_PARAM_PERCENT: // Remove Smallest Suffix Pattern
  	case MRSH_PARAM_DPERCENT: // Remove Largest Suffix Pattern

M test/word.sh => test/word.sh +2 -0
@@ 17,6 17,8 @@ echo \$a '$a'
  echo ${a:-BAD} ${idontexist:-GOOD} ${null:-GOOD} ${idontexist:-}
  echo ${a-BAD} ${idontexist-GOOD} ${null-BAD} ${null-}
+ echo ${a:+GOOD} ${idontexist:+BAD} ${null:+BAD} ${idontexist:+}
+ echo ${a+GOOD} ${idontexist+BAD} ${null-GOOD} ${null+}
  #echo ${#hello}
  
  echo ""