@@ -91,13 +91,24 @@ def create_inner(archive, cache, fso):
9191 else :
9292 status = "+" # included
9393 self .print_file_status (status , path )
94- elif args .paths_from_command or args .paths_from_stdin :
94+ elif args .paths_from_command or args .paths_from_shell_command or args . paths_from_stdin :
9595 paths_sep = eval_escapes (args .paths_delimiter ) if args .paths_delimiter is not None else "\n "
96- if args .paths_from_command :
96+ if args .paths_from_command or args . paths_from_shell_command :
9797 try :
9898 env = prepare_subprocess_env (system = True )
99+ if args .paths_from_shell_command :
100+ # Use shell=True to support pipes, redirection, etc.
101+ shell = True
102+ cmd = " " .join (args .paths )
103+ else :
104+ shell = False
105+ cmd = args .paths
99106 proc = subprocess .Popen ( # nosec B603
100- args .paths , stdout = subprocess .PIPE , env = env , preexec_fn = None if is_win32 else ignore_sigint
107+ cmd ,
108+ stdout = subprocess .PIPE ,
109+ env = env ,
110+ shell = shell ,
111+ preexec_fn = None if is_win32 else ignore_sigint ,
101112 )
102113 except (FileNotFoundError , PermissionError ) as e :
103114 raise CommandError (f"Failed to execute command: { e } " )
@@ -131,7 +142,7 @@ def create_inner(archive, cache, fso):
131142 self .print_file_status (status , path )
132143 if not dry_run and status is not None :
133144 fso .stats .files_stats [status ] += 1
134- if args .paths_from_command :
145+ if args .paths_from_command or args . paths_from_shell_command :
135146 rc = proc .wait ()
136147 if rc != 0 :
137148 raise CommandError (f"Command { args .paths [0 ]!r} exited with status { rc } " )
@@ -844,6 +855,11 @@ def build_parser_create(self, subparsers, common_parser, mid_common_parser):
844855 action = "store_true" ,
845856 help = "interpret PATH as command and treat its output as ``--paths-from-stdin``" ,
846857 )
858+ subparser .add_argument (
859+ "--paths-from-shell-command" ,
860+ action = "store_true" ,
861+ help = "interpret PATH as a shell command (be careful!) and treat its output as ``--paths-from-stdin``" ,
862+ )
847863 subparser .add_argument (
848864 "--paths-delimiter" ,
849865 action = Highlander ,
0 commit comments