diff --git a/src/expand.cpp b/src/expand.cpp index 396745476..4473b481f 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -649,7 +649,12 @@ static expand_result_t expand_cmdsubst(wcstring input, parser_t &parser, bad_pos = parse_slice(slice_begin, &slice_end, slice_idx, sub_res.size()); if (bad_pos != 0) { - append_syntax_error(errors, slice_begin - in + bad_pos, L"Invalid index value"); + if (tail_begin[bad_pos] == L'0') { + append_syntax_error(errors, slice_begin - in + bad_pos, + L"array indices start at 1, not 0."); + } else { + append_syntax_error(errors, slice_begin - in + bad_pos, L"Invalid index value"); + } return expand_result_t::make_error(STATUS_EXPAND_ERROR); }