rakitzis / rc

rc shell -- independent re-implementation for Unix of the Plan 9 shell (from circa 1992)
Other
250 stars 23 forks source link

Subscripting variables with single-integer list add unnecessary space #67

Closed viyic closed 3 years ago

viyic commented 3 years ago

When subscripting a variable with single-element list, it adds a space.

; a = b
; echo $a$a
bb
; echo $a(1)$a
b b

Which could be annoying if you want to echo a specific string.

; test_program hello
# msg = $*
# echo "$msg"
"hello"
# echo "$msg(1)"
"hello "
# msg1 = $msg(1)
# echo "$msg1"
"hello"
rakitzis commented 3 years ago

Please see the doc/design on "free carets". In any case, you can add a caret in this situation to get the behavior you want. $a(1)^$a

viyic commented 3 years ago

Ah yes, it works. Thank you!