[Rear-users] bash style

Schlomo Schapiro schlomo at schapiro.org
Sun Jun 19 12:26:11 CEST 2011


OK,

I am really against using [[ ]] in places where it behaves like [ ]. The reason
for that is that [[ carries the danger of unplanned pattern matches. And [[ code
&& code ]] is not a reason to change [ code -a code ], it adds no benefit and
even carries the risk of confusing the && within the [[]] with the && that can
be normally used.

Even though it is against my personal taste I am ready to go over that and use [
over test, IF the majority of the list prefers it that way.

Also, please use tabs and not spaces.

Kind Regards,
Schlomo

On 06/06/11 01:27, dag- at users.sourceforge.net wrote:
> Revision: 562
>           http://rear.svn.sourceforge.net/rear/?rev=562&view=rev
> Author:   dag-
> Date:     2011-06-05 23:27:01 +0000 (Sun, 05 Jun 2011)
> 
> Log Message:
> -----------
> Comestic changes
> 
> Modified Paths:
> --------------
>     trunk/usr/share/rear/build/GNU/Linux/39_copy_binaries_libraries.sh
>     trunk/usr/share/rear/build/GNU/Linux/40_copy_modules.sh
>     trunk/usr/share/rear/build/GNU/Linux/60_verify_and_adjust_udev.sh
> 
> Modified: trunk/usr/share/rear/build/GNU/Linux/39_copy_binaries_libraries.sh
> ===================================================================
> --- trunk/usr/share/rear/build/GNU/Linux/39_copy_binaries_libraries.sh	2011-06-05 23:24:58 UTC (rev 561)
> +++ trunk/usr/share/rear/build/GNU/Linux/39_copy_binaries_libraries.sh	2011-06-05 23:27:01 UTC (rev 562)
> @@ -19,23 +19,20 @@
>  #
>  
>  LogPrint "Copy program files & libraries"
> -{
> +
>  # calculate binaries from needed progs
> -declare -a BINARIES
> -c=0
> -for k in "${PROGS[@]}" "${REQUIRED_PROGS[@]}"; do
> -	file="$(type -p "$k")"
> -	if test -x "$file" ; then
> -		BINARIES[$c]="$file"
> -		let c++
> -		echo "Found $file"
> +declare -a BINARIES=( $(
> +for bin in "${PROGS[@]}" "${REQUIRED_PROGS[@]}"; do
> +	file="$(type -p "$bin")"
> +	if [[ -x "$file" ]]; then
> +		echo $file
> +		echo "Found $file" >&8
>  	fi
> -done
> -} 1>&8
> +done | sort -u) )
> +
>  # copy binaries
>  Log "Binaries: ${BINARIES[@]}"
> -BinCopyTo "$ROOTFS_DIR/bin" "${BINARIES[@]}"  1>&8
> -[ $PIPESTATUS -eq 0 ]
> +BinCopyTo "$ROOTFS_DIR/bin" "${BINARIES[@]}" >&8
>  StopIfError "Could not copy binaries"
>  
>  # split libs into lib and lib64 paths
> @@ -53,32 +50,26 @@
>  	#
>  	# we sort that into LIBS, LIBS32 and LIBS64 accordingly
>  	case "$lib" in
> -		(*lib32/*)	REAL_LIBS32=( ${REAL_LIBS32[@]} $lib ) ;;
> -		(*lib64/*)	REAL_LIBS64=( ${REAL_LIBS64[@]} $lib ) ;;
> -		(*)	REAL_LIBS=( ${REAL_LIBS[@]} $lib ) ;;
> +		(*lib32/*) REAL_LIBS32=( ${REAL_LIBS32[@]} $lib ) ;;
> +		(*lib64/*) REAL_LIBS64=( ${REAL_LIBS64[@]} $lib ) ;;
> +		(*) REAL_LIBS=( ${REAL_LIBS[@]} $lib ) ;;
>  	esac
>  done
>  
> -Log "Libraries: ${REAL_LIBS[@]}"
> -if test "$REAL_LIBS" ; then
> -	LibCopyTo "$ROOTFS_DIR/lib" ${REAL_LIBS[@]} 1>&8
> -	[ $PIPESTATUS -eq 0 ]
> +if [[ "$REAL_LIBS" ]]; then
> +	Log "Libraries: ${REAL_LIBS[@]}"
> +	LibCopyTo "$ROOTFS_DIR/lib" ${REAL_LIBS[@]} >&8
>  	StopIfError "Could not copy libraries"
>  fi
> -Log "Libraries(32): ${REAL_LIBS32[@]}"
> -if test "$REAL_LIBS32" ; then
> -	LibCopyTo "$ROOTFS_DIR/lib32" ${REAL_LIBS32[@]} 1>&8
> -	[ $PIPESTATUS -eq 0 ]
> +if [[ "$REAL_LIBS32" ]]; then
> +	Log "Libraries(32): ${REAL_LIBS32[@]}"
> +	LibCopyTo "$ROOTFS_DIR/lib32" ${REAL_LIBS32[@]} >&8
>  	StopIfError "Could not copy 32bit libraries"
>  fi
> -Log "Libraries(64): ${REAL_LIBS64[@]}"
> -if test "$REAL_LIBS64" ; then
> -	LibCopyTo "$ROOTFS_DIR/lib64" ${REAL_LIBS64[@]} 1>&8
> -	[ $PIPESTATUS -eq 0 ]
> +if [[ "$REAL_LIBS64" ]]; then
> +	Log "Libraries(64): ${REAL_LIBS64[@]}"
> +	LibCopyTo "$ROOTFS_DIR/lib64" ${REAL_LIBS64[@]} >&8
>  	StopIfError "Could not copy 64bit libraries"
>  fi
> -ldconfig $v -r "$ROOTFS_DIR" 1>&8
> -[ $PIPESTATUS -eq 0 ]
> +ldconfig $v -r "$ROOTFS_DIR" >&8
>  StopIfError "Could not configure libraries with ldconfig"
> -
> -
> 
> Modified: trunk/usr/share/rear/build/GNU/Linux/40_copy_modules.sh
> ===================================================================
> --- trunk/usr/share/rear/build/GNU/Linux/40_copy_modules.sh	2011-06-05 23:24:58 UTC (rev 561)
> +++ trunk/usr/share/rear/build/GNU/Linux/40_copy_modules.sh	2011-06-05 23:27:01 UTC (rev 562)
> @@ -19,21 +19,19 @@
>  #
>  
>  Log "Collecting modules for kernel version $KERNEL_VERSION"
> -LogPrint "Copy kernel modules"
>  MODFILES=(
>  $( ResolveModules "$KERNEL_VERSION" "${MODULES[@]}" "${MODULES_LOAD[@]}"  )
>  )
>  StopIfError "Could not resolve kernel module dependancies"
>  
>  # copy modules & depmod
> -Log "Copying kernel modules"
> -ModulesCopyTo "$ROOTFS_DIR" "${MODFILES[@]}" 1>&8 
> +LogPrint "Copying kernel modules"
> +ModulesCopyTo "$ROOTFS_DIR" "${MODFILES[@]}" >&8
>  StopIfError "Could not copy kernel modules"
>  
> -depmod -avb "$ROOTFS_DIR" "$KERNEL_VERSION" 1>&8 
> +depmod -avb "$ROOTFS_DIR" "$KERNEL_VERSION" >&8
>  StopIfError "Could not configure modules with depmod"
>  
>  for m in "${MODULES_LOAD[@]}" ; do
>  	echo $m
>  done >>$ROOTFS_DIR/etc/modules
> -
> 
> Modified: trunk/usr/share/rear/build/GNU/Linux/60_verify_and_adjust_udev.sh
> ===================================================================
> --- trunk/usr/share/rear/build/GNU/Linux/60_verify_and_adjust_udev.sh	2011-06-05 23:24:58 UTC (rev 561)
> +++ trunk/usr/share/rear/build/GNU/Linux/60_verify_and_adjust_udev.sh	2011-06-05 23:27:01 UTC (rev 562)
> @@ -46,7 +46,7 @@
>  	grep -nE '(PROGRAM|RUN)' etc/udev/rules.d/* lib/udev/rules.d/* | \
>  		sed -ne 's#\(^.*\):[0-9]\+:.*\(PROGRAM\|RUN\)[+!]\?="\([^"%\$ ]\+\).*#\3 \1#p' | \
>  		grep -v ^socket: | \
> -		sort -u \
> +		sort -u
>  	)
>  
>  # insert our module auto-loading rule
> 
> 
> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
> 
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Discover what all the cheering's about.
> Get your free trial download today. 
> http://p.sf.net/sfu/quest-dev2dev2 
> _______________________________________________
> Rear-users mailing list
> Rear-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rear-users




More information about the rear-users mailing list