Commit e0ca51b 1 parent 64e9e30 commit e0ca51b Copy full SHA for e0ca51b
File tree 2 files changed +22
-11
lines changed
2 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -286,10 +286,11 @@ def _ReadSliceVarOp(self):
286
286
if self .token_type != Id .Arith_RBrace :
287
287
length = self ._ReadArithExpr (Id .Arith_RBrace )
288
288
else :
289
- p_die ('Use explicit slice length of zero' ,
290
- self .cur_token )
291
- # bash behavior
292
- # length = arith_expr.EmptyZero # ${a:1:} or ${a::}
289
+ # quirky bash behavior:
290
+ # ${a:1:} or ${a::} means zero length
291
+ # but ${a:1} or ${a:} means length N
292
+ length = arith_expr .EmptyZero
293
+
293
294
return suffix_op .Slice (begin , length )
294
295
295
296
elif cur_id == Id .Arith_RBrace : # ${a:1} or ${@:1}
Original file line number Diff line number Diff line change @@ -367,22 +367,32 @@ $SH -c 's=123; argv.py space ${s: }'
367
367
[' space' , ' 123' ]
368
368
# # END
369
369
370
- # ### don't agree with ${array[@]::} has implicit length of zero!
370
+ # ### ${array[@]::} has implicit length of zero - for ble.sh
371
+
372
+ # https://oilshell.zulipchat.com/#narrow/stream/121540-oil-discuss/topic/.24.7Barr.5B.40.5D.3A.3A.7D.20in.20bash.20-.20is.20it.20documented.3F
373
+
371
374
array=(1 2 3)
372
375
argv.py ${array[@]:: }
376
+ argv.py ${array[@]: 0: }
377
+
378
+ echo
373
379
374
380
set -- 1 2 3
375
- # argv.py ${@:}
376
381
argv.py ${@:: }
382
+ argv.py ${@: 0: }
377
383
378
- # # status: 1
379
- # # stdout-json: ""
384
+ # # status: 0
385
+ # # STDOUT:
380
386
381
- # # OK osh status: 2
387
+ # # status: 0
388
+ # # STDOUT:
389
+ []
390
+ []
382
391
383
- # # N-I bash status: 0
384
- # # N-I bash STDOUT:
385
392
[]
386
393
[]
387
394
# # END
388
395
396
+ # # OK mksh/zsh status: 1
397
+ # # OK mksh/zsh STDOUT:
398
+ # # END
You can’t perform that action at this time.
0 commit comments