diff --git a/src/lib/eval.ml b/src/lib/eval.ml index 806b87a..ea60340 100644 --- a/src/lib/eval.ml +++ b/src/lib/eval.ml @@ -1065,7 +1065,20 @@ module Make (S : Types.State) (E : Types.Exec) = struct match inner_acc with | Some _ as v -> v | None -> - let pattern = word_cst_to_string pattern in + let _, pattern = + word_expansion + { + ctx with + options = + Built_ins.Options.with_options + ~no_path_expansion:true ctx.options; + } + pattern + in + let pattern = + Ast.Fragment.join_list ~sep:"" + (List.concat pattern) + in if Glob.test ~pattern scrutinee then begin match sub with | Some sub -> Some (exec_subshell ctx sub) diff --git a/test/cases.t b/test/cases.t index 1dce083..c244038 100644 --- a/test/cases.t +++ b/test/cases.t @@ -37,3 +37,27 @@ Case compound command All good... Stopping service Unknown command: foo + + + $ cat > test.sh << EOF + > contains () { + > case \$1 in + > *\$2*) + > echo "Yep, \$2 is in \$1" + > ;; + > *) + > echo "\$1 does not contain \$2" + > ;; + > esac + > } + > + > contains "radar" "ada" + > contains "hello" "ee" + > EOF + + $ sh test.sh + Yep, ada is in radar + hello does not contain ee + $ msh test.sh + Yep, ada is in radar + hello does not contain ee