summaryrefslogtreecommitdiffhomepage
path: root/subr.rtl
diff options
context:
space:
mode:
authorLucía Andrea Illanes Albornoz <lucia@luciaillanes.de>2023-03-27 08:04:23 +0200
committerLucía Andrea Illanes Albornoz <lucia@luciaillanes.de>2023-03-27 08:04:23 +0200
commit938c5c45b976387ceea5792b0ce9717dd97667eb (patch)
treef0dfdb3728fe7b62aef4a395f24f8e66cf85d824 /subr.rtl
parent0753bb40540d5f1754ddd508614b3b606e10bd93 (diff)
downloadmidipix_build-938c5c45b976387ceea5792b0ce9717dd97667eb.tar.bz2
midipix_build-938c5c45b976387ceea5792b0ce9717dd97667eb.tar.xz
Generalise subr.pkg/*.subr code.
Diffstat (limited to 'subr.rtl')
-rw-r--r--subr.rtl/rtl_filepath.subr59
-rw-r--r--subr.rtl/rtl_platform.subr1
2 files changed, 59 insertions, 1 deletions
diff --git a/subr.rtl/rtl_filepath.subr b/subr.rtl/rtl_filepath.subr
index 3e24057f..a2f0f5c4 100644
--- a/subr.rtl/rtl_filepath.subr
+++ b/subr.rtl/rtl_filepath.subr
@@ -213,7 +213,7 @@ rtl_is_newer() {
};
#
-# rtl_patch_files() -
+# rtl_patch_files() - patch files
# @_patch_cwd: patch(1) -d directory
# @_strip_count: patch(1) strip count
# @_fn: name of function that produces patch filenames and takes the arguments @_rpatch_fname @_patch_idx @...
@@ -246,4 +246,61 @@ rtl_patch_files() {
return 0;
};
+#
+# rtl_set_perms_treeV() - set mode bits of directories and files
+# @_mode_dir: mode bits for directories
+# @_mode_file_exec: mode bits for executable files
+# @_mode_file_nonexec: mode bits for non-executable files
+# @...: list of base directory pathnames as positional parameters; empty strings are ignored
+#
+# Returns: zero (0) on success, non-zero (>0) on failure
+#
+rtl_set_perms_treeV() {
+ local _rspt_mode_dir="${1}" _rspt_mode_file_exec="${2}" _rspt_mode_file_nonexec="${3}" \
+ _rspt_destdir="" _rspt_fname="" \
+ IFS IFS0="${IFS}";
+ shift 3;
+
+ for _rspt_destdir in "${@}"; do
+ if [ -e "${_rspt_destdir}" ]; then
+ rtl_set_IFS_nl;
+
+ for _rspt_fname in $(find "${_rspt_destdir}" -type d); do
+ if ! rtl_fileop chmod "${_rspt_mode_dir}" \
+ "${_rspt_fname}";
+ then
+ return 1;
+ fi;
+ done;
+
+ for _rspt_fname in $(find \
+ "${_rspt_destdir}" \
+ \( -not -perm /0111 \) \
+ -type f);
+ do
+ if ! rtl_fileop chmod "${_rspt_mode_file_nonexec}" \
+ "${_rspt_fname}";
+ then
+ return 1;
+ fi;
+ done;
+
+ for _rspt_fname in $(find \
+ "${_rspt_destdir}" \
+ -perm /0111 \
+ -type f);
+ do
+ if ! rtl_fileop chmod "${_rspt_mode_file_exec}" \
+ "${_rspt_fname}";
+ then
+ return 1;
+ fi;
+ done;
+
+ IFS="${IFS0}";
+ fi;
+ done;
+ return 0;
+};
+
# vim:filetype=sh textwidth=0
diff --git a/subr.rtl/rtl_platform.subr b/subr.rtl/rtl_platform.subr
index 9fc7b013..d3ba8f56 100644
--- a/subr.rtl/rtl_platform.subr
+++ b/subr.rtl/rtl_platform.subr
@@ -237,6 +237,7 @@ rtl_set_var() {
# N.B.: This function is *unsafe* and impossible to implement otherwise w/o filtering @_vname
# and implicitly allows for code execution and other undefined behaviour via @_vname.
# Do *not* pass untrusted input through @_vname.
+#
rtl_set_var_unsafe() {
local _rsvu_vname="" _rsvu_vval="";
if [ "x${1}" = "x-u" ]; then