600
600
601
601
# ### Empty expression: $(())
602
602
case $SH in (dash) exit 1;; esac
603
+ shopt -s parse_empty_arith 2> /dev/null
603
604
echo 1:$( ())
604
605
echo 2:$(( ))
605
606
# # STDOUT:
@@ -613,6 +614,7 @@ echo 2:$(( ))
613
614
# dash/mksh doesn't support $[]
614
615
# oil has different meaning for $[]
615
616
case ${SH##*/ } in (dash|mksh|osh) exit 1;; esac
617
+ shopt -s parse_empty_arith 2> /dev/null
616
618
echo 3:$[]
617
619
echo 4:$[ ]
618
620
# # STDOUT:
@@ -624,6 +626,7 @@ echo 4:$[ ]
624
626
625
627
# ### Empty expression: (())
626
628
case $SH in (dash) exit 1;; esac
629
+ shopt -s parse_empty_arith 2> /dev/null
627
630
(( )) && echo unexpected || echo OK
628
631
(( )) && echo unexpected || echo OK
629
632
! (( )) && echo OK || echo unexpected
@@ -643,6 +646,7 @@ case $SH in
643
646
(mksh|zsh) exit 1;; # mksh/zsh does not support.
644
647
(bash) exit 1;; # bash supports this from bash-5.0.
645
648
esac
649
+ shopt -s parse_empty_arith 2> /dev/null
646
650
647
651
arr=(foo bar)
648
652
echo " ${arr[ ]} "
655
659
# ### Empty expression: ${var::}
656
660
case $SH in
657
661
(dash) exit 1;; # dash does not support arrays.
658
- (dash) exit 1;; # zsh does not support empty offset/length.
662
+ (zsh) exit 1;; # zsh does not support empty offset/length.
659
663
esac
664
+ shopt -s parse_empty_arith 2> /dev/null
665
+
660
666
var=abcd
661
667
echo " 1:[${var:: 1} ]"
662
668
echo " 2:[${var: : 1} ]"
@@ -681,6 +687,7 @@ case $SH in
681
687
(mksh) exit 1;; # mksh does not support ${array[@]:offset:length}
682
688
(zsh) exit 1;; # zsh does not support empty offset/length
683
689
esac
690
+ shopt -s parse_empty_arith 2> /dev/null
684
691
array=(1 2 3)
685
692
argv.py " ${array[@]:: 1} "
686
693
argv.py " ${array[@]: : 1} "
0 commit comments