fork download
  1. #!/bin/bash
  2.  
  3. function test_expansion() {
  4. echo "${@:1:$#-1}"
  5. }
  6.  
  7. test_expansion 1 2 3 4
  8. test_expansion 1 2 3
  9. test_expansion 1 # outputs an empty line
  10. test_expansion # raises the error seen on stdout
Runtime error #stdin #stdout #stderr 0s 4236KB
stdin
Standard input is empty
stdout
1 2 3
1 2

stderr
./prog.sh: line 4: $#-1: substring expression < 0