From bf23dece9f63633a751b8c7d6e16f07f5d59071e Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 09 Oct 2012 21:46:21 -0400 Subject: Replace unsafe/unnecessary ls command in for loop. --- (limited to 'src') diff --git a/src/ob-applypatches.sh b/src/ob-applypatches.sh index 7b43d41..37a8cc3 100644 --- a/src/ob-applypatches.sh +++ b/src/ob-applypatches.sh @@ -41,12 +41,19 @@ apply_patches() if [ -d '../patches' ]; then # Iterate over patches ordered alphabetically by name. - for patch in $(ls -1 '../patches' | sort); do + # POSIX.1-2008 says that the results of a pathname expansion shall be + # "sorted according to the collating sequence in effect in the current + # locale". So for consistent results, we first set a standard locale. + orig_lang="${LANG}" + LANG='POSIX' + for patch in '../patches/'*; do + LANG="${orig_lang}" ob_info "$(ob_get_msg 'applying_patch')" "${patch}" patch -N -p 1 -u -d 'src' -i "../../patches/${patch}" || \ ob_error "$(ob_get_msg 'cant_apply_patch')" "${patch}" applied='true' done + LANG="${orig_lang}" fi ${applied} || ob_info "$(ob_get_msg 'no_patches')" -- cgit v0.9.1