# HG changeset patch # User Atul Varma # Date 1228876785 28800 # Node ID 90eafff62b9796c4a3395ff63a50defab4de01e7 # Parent 14f4251b156c8be99bcb76b5986db312de306f5e hrm now behaves like rm with the '-f' switch by default, so that it doesn't abort and return with a nonzero exit code if a file parameter doesn't exist. This makes it much more compatible with existing build scripts that use rm. diff -r 14f4251b156c -r 90eafff62b97 hrm.py --- a/hrm.py Tue Dec 09 13:25:09 2008 -0800 +++ b/hrm.py Tue Dec 09 18:39:45 2008 -0800 @@ -39,6 +39,10 @@ # TODO: # +# * If the '-f' parameter isn't supplied, hrm should exit with a +# nonzero exit code if a file doesn't exist to maintain compatibility +# with rm. +# # * Consider adding support for "max size" based removal, so that # if a certain quota is exceeded, the minimum number of files are # removed to satisfy the quota. @@ -184,7 +188,7 @@ filename = os.path.abspath(os.path.expanduser(arg)) if not os.path.exists(filename): print('File does not exist: %s' % arg) - sys.exit(-1) + continue realpath = os.path.realpath(filename) if (realpath.startswith(HADES_DIR) or HADES_DIR.startswith(realpath)): @@ -192,6 +196,11 @@ sys.exit(-1) files.append(filename) + if not files: + # For compatibility with 'rm -f', just exit w/ no + # error code. + sys.exit(0) + thisid = config.nextid basedir = dir_for_trans(thisid) shell('mkdir', basedir)