From 96b160c9c576b02b6ed4d06f07526bfbbd4854fa Mon Sep 17 00:00:00 2001 From: Aivaria Date: Sun, 13 Jul 2025 21:52:48 +0200 Subject: [PATCH] Update chmod.src added the option for linux like chmod. --- commands/chmod.src | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/commands/chmod.src b/commands/chmod.src index 68fb69d..ecd76ca 100644 --- a/commands/chmod.src +++ b/commands/chmod.src @@ -19,14 +19,30 @@ chmodFile.run = function(object, args) pathFile = args[2] isRecursive = 1 end if + if permissions.is_match("[0-7]{3}") then + ugo = "ugo" + file = findFile(object, pathFile) + if file == null then; print("chmod: can't find " + pathFile); return; end if + for i in range(len(permissions)-1) + addPerm = ugo[i]+"+" + rmPerm = ugo[i]+"-" - file = findFile(object, pathFile) - if file == null then; print("chmod: can't find " + pathFile); return; end if - output = file.chmod(permissions, isRecursive) - if output then print(output) + if bitwise("&",permissions[i].val,4) then addPerm=addPerm+"r" else rmPerm=rmPerm+"r" + if bitwise("&",permissions[i].val,2) then addPerm=addPerm+"w" else rmPerm=rmPerm+"w" + if bitwise("&",permissions[i].val,1) then addPerm=addPerm+"x" else rmPerm=rmPerm+"x" + if addPerm != ugo[i]+"+" then output = file.chmod(addPerm, isRecursive) + if rmPerm != ugo[i]+"-" then output = file.chmod(rmPerm, isRecursive) + end for + if output then print(output) + else + file = findFile(object, pathFile) + if file == null then; print("chmod: can't find " + pathFile); return; end if + output = file.chmod(permissions, isRecursive) + if output then print(output) + end if end function chmodFile.show_help = function() show_help(self.name, self.args, self.full_desc, self.handler_types) -end function \ No newline at end of file +end function