(* A word the shell passes on as it is written: no quote, expansion, assignment, glob, redirection or separator; any other is single-quoted. *) let word s = let plain = function | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '.' | '_' | '-' | '/' | '+' | '@' | ',' | ':' -> true | _ -> false in if s <> "" && String.for_all plain s then s else Filename.quote s