in cortado/rtas/builtin_cmd_file_delete.py [0:0]
def main():
masquerade = "/tmp/xargs"
masquerade2 = "/tmp/rm"
# used only for linux at 2 places to enumerate xargs as parent process.
working_dir = "/tmp/fake_folder/xargs"
if _common.get_current_os() == OSType.LINUX:
# Using the Linux binary that simulates parent-> child process in Linux
source = _common.get_resource_path("bin/linux_ditto_and_spawn_parent_child")
_common.copy_file(source, masquerade)
_common.copy_file(source, masquerade2)
# As opposed to macos, where the masquerade is being projected as parent process,
# in linux the working directory is being projected as parent process.
# Hence, to simulate the parent process without many changes to execute logic
# a fake folder structure is created for execution.
# The execution working directory is changed to the fake folder, to simulate as xargs parent process in Linux.
pathlib.Path(working_dir).mkdir(parents=True, exist_ok=True)
os.chdir(working_dir)
else:
_common.create_macos_masquerade(masquerade)
_common.create_macos_masquerade(masquerade2)
# Execute command
log.info("Launching fake builtin commands to recursively delete")
command = f"{masquerade2} -rf arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 arg10 /home/test"
_ = _common.execute_command([masquerade, "childprocess", command], timeout_secs=10)
# cleanup
_common.remove_file(masquerade)
_common.remove_file(masquerade2)
current_os = _common.get_current_os()
if current_os == OSType.LINUX:
_common.remove_directory(working_dir)