Panic parsing double-quoted string containing [] twice
Created by: jbg
Reproduction: (on latest master)
jbg:~# env RUST_BACKTRACE=1 dev/ion/target/release/ion
jbg:~# echo "[] []"
thread 'main' panicked at 'byte index 8 is out of bounds of `"[] []"`', /checkout/src/libcore/str/mod.rs:2215:8
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::panicking::default_hook::{{closure}}
at /checkout/src/libstd/sys_common/backtrace.rs:71
at /checkout/src/libstd/sys_common/backtrace.rs:60
at /checkout/src/libstd/panicking.rs:381
2: std::panicking::rust_panic_with_hook
at /checkout/src/libstd/panicking.rs:397
at /checkout/src/libstd/panicking.rs:577
3: std::panicking::begin_panic
at /checkout/src/libstd/panicking.rs:538
4: std::panicking::begin_panic_fmt
at /checkout/src/libstd/panicking.rs:522
5: core::panicking::panic_fmt
at /checkout/src/libstd/panicking.rs:498
6: core::str::slice_error_fail
at /checkout/src/libcore/str/mod.rs:2215
7: <ion::parser::shell_expand::words::WordIterator<'a, E> as core::iter::iterator::Iterator>::next
8: ion::parser::shell_expand::expand_string
9: ion::parser::pipelines::Pipeline::expand
10: ion::shell::Shell::run_pipeline
11: <ion::shell::Shell<'a> as ion::shell::flow::FlowLogic>::execute_toplevel
12: <ion::shell::Shell<'a> as ion::shell::flow::FlowLogic>::on_command
13: ion::main
14: main
15: __libc_start_main
16: _start
ion: process ended by signal
Note that it also happens if you put something inside the brackets.
Expected behavior: I expected literally [] []
to be echoed, but I'm not sure. Maybe they should be expanded to empty arrays and thus eliminated? The book didn't make it clear to me. The quoting rules are not clear to me with a single instance of []
either:
jbg:~# echo "[]"
[]"
Build information:
jbg:~# rustc -V
rustc 1.22.0-nightly (0e6f4cf51 2017-09-27)
jbg:~# uname -a
Linux catalan 4.13.4-1-ARCH #1 SMP PREEMPT Thu Sep 28 08:39:52 CEST 2017 x86_64 GNU/Linux
jbg:~# dev/ion/target/release/ion --version
ion 1.0.5 (x86_64-unknown-linux-gnu)
rev a8c22d161eeb38f7234e1e3453d24ab5927c976f