From 3119249761589e21dbc57ac670a81b3563aa6330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 25 Sep 2011 23:44:11 +0300 Subject: [PATCH 3/3] Avoid some unnecessary stat calls. --- scripts/xdg-desktop-menu.in | 8 ++++---- scripts/xdg-email.in | 2 +- scripts/xdg-icon-resource.in | 6 +++--- scripts/xdg-settings.in | 6 +++--- scripts/xdg-utils-common.in | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/xdg-desktop-menu.in b/scripts/xdg-desktop-menu.in index 6c1e3a3..431ac2a 100644 --- a/scripts/xdg-desktop-menu.in +++ b/scripts/xdg-desktop-menu.in @@ -158,7 +158,7 @@ update_submenu() return fi - if [ $action = "install" -a -f "/etc/xdg/menus/gnome-applications.menu" ] ; then + if [ $action = "install" ] && [ -f "/etc/xdg/menus/gnome-applications.menu" ] ; then # Work around for Debian Gnome gnome_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/gnome-applications-merged^'` if [ ! -e "$gnome_xdg_dir" ] ; then @@ -167,7 +167,7 @@ update_submenu() eval 'ln -s "applications-merged" "$gnome_xdg_dir"'$xdg_redirect_output fi fi - if [ $action = "install" -a -f "/etc/mandrake-release" ] ; then + if [ $action = "install" ] && [ -f "/etc/mandrake-release" ] ; then # Work around for Mandriva 2006 mandrake_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/applications-mdk-merged^'` if [ ! -e "$mandrake_xdg_dir" ] ; then @@ -176,7 +176,7 @@ update_submenu() eval 'ln -s "applications-merged" "$mandrake_xdg_dir"'$xdg_redirect_output fi fi - if [ $action = "install" -a x"$mode" = x"user" -a -d "/etc/xdg/menus/kde-applications-merged" ] ; then + if [ $action = "install" -a x"$mode" = x"user" ] && [ -d "/etc/xdg/menus/kde-applications-merged" ] ; then # Work around for Fedora Core 5 + patched KDE kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'` if [ ! -e "$kde_xdg_dir" ] ; then @@ -185,7 +185,7 @@ update_submenu() eval 'ln -s "applications-merged" "$kde_xdg_dir"'$xdg_redirect_output fi fi - if [ $action = "install" -a x"$mode" = x"system" -a -d "/etc/xdg/menus/kde-applications-merged" -a ! -d "/etc/xdg/menus/applications-merged" ] ; then + if [ $action = "install" -a x"$mode" = x"system" ] && [ -d "/etc/xdg/menus/kde-applications-merged" ] && [ ! -d "/etc/xdg/menus/applications-merged" ] ; then # Work around for Kubuntu 6.06 kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'` DEBUG 1 "Kubuntu Workaround: Link '$xdg_dir' to 'kde-applications-merged'" diff --git a/scripts/xdg-email.in b/scripts/xdg-email.in index e67abb4..4c3cb83 100644 --- a/scripts/xdg-email.in +++ b/scripts/xdg-email.in @@ -304,7 +304,7 @@ while [ $# -gt 0 ] ; do fi check_input_file "$1" file=`readlink -f "$1"` # Normalize path - if [ -z "$file" -o ! -f "$file" ] ; then + if [ -z "$file" ] || [ ! -f "$file" ] ; then exit_failure_file_missing "file '$1' does not exist" fi diff --git a/scripts/xdg-icon-resource.in b/scripts/xdg-icon-resource.in index ca81a8b..be1ad58 100644 --- a/scripts/xdg-icon-resource.in +++ b/scripts/xdg-icon-resource.in @@ -254,7 +254,7 @@ if [ x"$action" = x"forceupdate" ] ; then fi update_icon_database $xdg_base_dir if [ -n "$dot_icon_dir" ] ; then - if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then + if [ -d "$dot_icon_dir/" ] && [ ! -L "$dot_icon_dir" ] ; then update_icon_database $dot_base_dir fi fi @@ -394,7 +394,7 @@ icon_icon_file=`echo "$icon_file" | sed 's/\.[a-z][a-z][a-z]$/.icon/'` icon_icon_name="$icon_name.icon" DEBUG 1 "$action icon in $xdg_dir" -[ $action = "install" -a -f $icon_icon_file ] && DEBUG 1 "install $icon_icon_name meta file in $xdg_dir" +[ $action = "install" ] && [ -f $icon_icon_file ] && DEBUG 1 "install $icon_icon_name meta file in $xdg_dir" [ -n "$kde_dir" ] && DEBUG 1 "$action symlink in $kde_dir (KDE 3.x support)" [ -n "$need_gnome_mime" ] && DEBUG 1 "$action gnome-mime-$icon_name symlink (GNOME 2.x support)" [ $action = "install" -a -n "$dot_icon_dir" ] && DEBUG 1 "$action ~/.icons symlink (GNOME 2.8 support)" @@ -441,7 +441,7 @@ esac if [ x"$update" = x"yes" ] ; then update_icon_database "$xdg_base_dir" if [ -n "$dot_icon_dir" ] ; then - if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then + if [ -d "$dot_icon_dir/" ] && [ ! -L "$dot_icon_dir" ] ; then update_icon_database $dot_base_dir fi fi diff --git a/scripts/xdg-settings.in b/scripts/xdg-settings.in index 8108b12..8c11859 100644 --- a/scripts/xdg-settings.in +++ b/scripts/xdg-settings.in @@ -349,7 +349,7 @@ get_browser_xfce() IFS=: for dir in $search; do unset IFS - [ "$dir" -a -d "$dir/xfce4" ] || continue + [ "$dir" ] && [ -d "$dir/xfce4" ] || continue file="$dir/xfce4/helpers.rc" [ -r "$file" ] || continue grep -q "^WebBrowser=" "$file" || continue @@ -382,7 +382,7 @@ check_xfce_desktop_file() IFS=: for dir in $search; do unset IFS - [ "$dir" -a -d "$dir/xfce4/helpers" ] || continue + [ "$dir" ] && [ -d "$dir/xfce4/helpers" ] || continue file="$dir/xfce4/helpers/$1" # We have the file, no need to create it. [ -r "$file" ] && return @@ -390,7 +390,7 @@ check_xfce_desktop_file() IFS=: for dir in $search; do unset IFS - [ "$dir" -a -d "$dir/applications" ] || continue + [ "$dir" ] && [ -d "$dir/applications" ] || continue file="$dir/applications/$1" if [ -r "$file" ]; then # Found a file to convert. diff --git a/scripts/xdg-utils-common.in b/scripts/xdg-utils-common.in index cea6646..ee13a1d 100644 --- a/scripts/xdg-utils-common.in +++ b/scripts/xdg-utils-common.in @@ -30,7 +30,7 @@ binary_to_desktop_file() for dir in $search; do unset IFS [ "$dir" ] || continue - [ -d "$dir/applications" -o -d "$dir/applnk" ] || continue + [ -d "$dir/applications" ] || [ -d "$dir/applnk" ] || continue for file in "$dir"/applications/*.desktop "$dir"/applications/*/*.desktop "$dir"/applnk/*.desktop "$dir"/applnk/*/*.desktop; do [ -r "$file" ] || continue # Check to make sure it's worth the processing. @@ -58,7 +58,7 @@ desktop_file_to_binary() IFS=: for dir in $search; do unset IFS - [ "$dir" -a -d "$dir/applications" ] || continue + [ "$dir" ] && [ -d "$dir/applications" ] || continue file="$dir/applications/$desktop" [ -r "$file" ] || continue # Remove any arguments (%F, %f, %U, %u, etc.). @@ -199,7 +199,7 @@ check_output_file() fi else DIR=`dirname "$1"` - if [ ! -w "$DIR" -o ! -x "$DIR" ]; then + if [ ! -w "$DIR" ] || [ ! -x "$DIR" ]; then exit_failure_file_permission_write "no permission to create file '$1'" fi fi -- 1.7.6