From 8b8e82f579adeb80b1fd021297f9a033f84c473e Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 1 Jan 2018 02:05:12 -0800 Subject: [PATCH] Util.pm: add is_shellish function The return value indicates whether or not the argument passed to the is_shellish function most likely needs to be handled using "sh -c" or not. Signed-off-by: Kyle J. McKay --- Girocco/Util.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Girocco/Util.pm b/Girocco/Util.pm index 9388b7e..4acb1e1 100644 --- a/Girocco/Util.pm +++ b/Girocco/Util.pm @@ -22,7 +22,8 @@ BEGIN { calc_bigfilethreshold has_reserved_suffix noFatalsToBrowser calc_redeltathreshold clean_email_multi read_HEAD_symref read_config_file - read_config_file_hash is_git_dir git_bool util_path); + read_config_file_hash is_git_dir git_bool util_path + is_shellish); } my $encoder; @@ -1224,4 +1225,14 @@ sub util_path { } } +# Note that Perl performs a "shellish" test in the Perl_do_exec3 function from doio.c, +# but it has slightly different semantics in that whitespace does not automatically +# make something "shellish". The semantics used here more closely match Git's +# semantics so that Girocco will provide an interpretation more similar to Git's. +sub is_shellish { + return unless defined(local $_ = shift); + return 1 if m#[][\$&*(){}'";:=\\|?<>~`\#\s]#; # contains metacharacters + return 0; # probably not shellish +} + 1; -- 2.11.4.GIT