All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH] Remove the usage of "local" in scripts
Date: Tue, 08 Nov 2011 14:44:47 +0100	[thread overview]
Message-ID: <4EB9324F.507@gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 154 bytes --]

Hello, all. While I'm not particularly fond of this change we need our
scripts to be portable

-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: eliminate_local.diff --]
[-- Type: text/x-diff; name="eliminate_local.diff", Size: 3861 bytes --]

=== modified file 'util/grub-mkconfig_lib.in'
--- util/grub-mkconfig_lib.in	2011-09-05 12:58:33 +0000
+++ util/grub-mkconfig_lib.in	2011-11-08 13:19:18 +0000
@@ -167,21 +167,21 @@
 
 version_test_numeric ()
 {
-  local a="$1"
-  local cmp="$2"
-  local b="$3"
-  if [ "$a" = "$b" ] ; then
-    case "$cmp" in
+  version_test_numeric_a="$1"
+  version_test_numeric_cmp="$2"
+  version_test_numeric_b="$3"
+  if [ "$version_test_numeric_a" = "$version_test_numeric_b" ] ; then
+    case "$version_test_numeric_cmp" in
       ge|eq|le) return 0 ;;
       gt|lt) return 1 ;;
     esac
   fi
-  if [ "$cmp" = "lt" ] ; then
-    c="$a"
-    a="$b"
-    b="$c"
+  if [ "$version_test_numeric_cmp" = "lt" ] ; then
+    version_test_numeric_c="$version_test_numeric_a"
+    version_test_numeric_a="$version_test_numeric_b"
+    version_test_numeric_b="$version_test_numeric_c"
   fi
-  if (echo "$a" ; echo "$b") | sort -n | head -n 1 | grep -qx "$b" ; then
+  if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | sort -n | head -n 1 | grep -qx "$version_test_numeric_b" ; then
     return 0
   else
     return 1
@@ -190,30 +190,30 @@
 
 version_test_gt ()
 {
-  local a="`echo "$1" | sed -e "s/[^-]*-//"`"
-  local b="`echo "$2" | sed -e "s/[^-]*-//"`"
-  local cmp=gt
-  if [ "x$b" = "x" ] ; then
+  version_test_gt_a="`echo "$1" | sed -e "s/[^-]*-//"`"
+  version_test_gt_b="`echo "$2" | sed -e "s/[^-]*-//"`"
+  version_test_gt_cmp=gt
+  if [ "x$version_test_gt_b" = "x" ] ; then
     return 0
   fi
-  case "$a:$b" in
+  case "$version_test_gt_a:$version_test_gt_b" in
     *.old:*.old) ;;
-    *.old:*) a="`echo -n "$a" | sed -e 's/\.old$//'`" ; cmp=gt ;;
-    *:*.old) b="`echo -n "$b" | sed -e 's/\.old$//'`" ; cmp=ge ;;
+    *.old:*) version_test_gt_a="`echo -n "$version_test_gt_a" | sed -e 's/\.old$//'`" ; cmp=gt ;;
+    *:*.old) version_test_gt_b="`echo -n "$version_test_gt_b" | sed -e 's/\.old$//'`" ; cmp=ge ;;
   esac
-  version_test_numeric "$a" "$cmp" "$b"
+  version_test_numeric "$version_test_gt_a" "$version_test_gt_cmp" "$version_test_gt_b"
   return "$?"
 }
 
 version_find_latest ()
 {
-  local a=""
+  version_find_latest_a=""
   for i in "$@" ; do
-    if version_test_gt "$i" "$a" ; then
-      a="$i"
+    if version_test_gt "$i" "$version_find_latest_a" ; then
+      version_find_latest_a="$i"
     fi
   done
-  echo "$a"
+  echo "$version_find_latest_a"
 }
 
 # One layer of quotation is eaten by "", the second by sed, and the third by
@@ -227,9 +227,9 @@
 # remaining arguments to printf.  This is a useful abbreviation and tends to
 # be easier to type.
 gettext_printf () {
-  local format="$1"
+  gettext_printf_format="$1"
   shift
-  printf "$(gettext_quoted "$format")" "$@"
+  printf "$(gettext_quoted "$gettext_printf_format")" "$@"
 }
 
 uses_abstraction () {

=== modified file 'util/grub.d/10_windows.in'
--- util/grub.d/10_windows.in	2011-10-23 20:40:26 +0000
+++ util/grub.d/10_windows.in	2011-11-08 13:43:38 +0000
@@ -42,14 +42,14 @@
     sort | uniq | wc -l`" = 1 || return 1
 
   # Search 'default=PARTITION'
-  local part=`sed -n 's,^default=,,p' "$1" | sed 's,\\\\,/,g;s,[ \t\r]*$,,;1q'`
-  test -n "$part" || return 1
+  get_os_name_from_boot_ini_part=`sed -n 's,^default=,,p' "$1" | sed 's,\\\\,/,g;s,[ \t\r]*$,,;1q'`
+  test -n "$get_os_name_from_boot_ini_part" || return 1
 
   # Search 'PARTITION="NAME" ...'
-  local name=`sed -n 's,\\\\,/,g;s,^'"$part"'="\([^"]*\)".*$,\1,p' "$1" | sed 1q`
-  test -n "$name" || return 1
+  get_os_name_from_boot_ini_name=`sed -n 's,\\\\,/,g;s,^'"$get_os_name_from_boot_ini_part"'="\([^"]*\)".*$,\1,p' "$1" | sed 1q`
+  test -n "$get_os_name_from_boot_ini_name" || return 1
 
-  echo "$name"
+  echo "$get_os_name_from_boot_ini_name"
 }
 
 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

                 reply	other threads:[~2011-11-08 13:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EB9324F.507@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.