[arch-general] [PATCH 05/48] a little creative parameter expansion simplifies stat_die()

2010-06-30 Thread Victor Lowther
---
 functions |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/functions b/functions
index 9b348b7..0acdbbf 100644
--- a/functions
+++ b/functions
@@ -57,7 +57,7 @@ if [[ $USECOLOR = YES || $USECOLOR = yes ]]; then
C_CLEAR=\033[1;0m
 fi
 
-if [ -t 1 ]; then
+if [[ -t 1 ]]; then
SAVE_POSITION=\033[s
RESTORE_POSITION=\033[u
DEL_TEXT=\033[$(($STAT_COL+4))G
@@ -116,10 +116,8 @@ stat_fail() {
 }
 
 stat_die() {
-   retval=1
-   [ $1 =  ] || retval=$1
stat_fail
-   exit $retval
+   exit ${1:-1}
 }
 
 status() {
-- 
1.7.1



Re: [arch-general] [PATCH 05/48] a little creative parameter expansion simplifies stat_die()

2010-06-30 Thread Thomas Bächler
Nice patch, but ...

 -if [ -t 1 ]; then
 +if [[ -t 1 ]]; then
   SAVE_POSITION=\033[s
   RESTORE_POSITION=\033[u
   DEL_TEXT=\033[$(($STAT_COL+4))G
 @@ -116,10 +116,8 @@ stat_fail() {

Hmm, this definitely doesn't belong into this patch.

  }
  
  stat_die() {
 - retval=1
 - [ $1 =  ] || retval=$1
   stat_fail
 - exit $retval
 + exit ${1:-1}
  }
  
  status() {

Okay, this is certainly nicer than before.



signature.asc
Description: OpenPGP digital signature


Re: [arch-general] [PATCH 05/48] a little creative parameter expansion simplifies stat_die()

2010-06-30 Thread Victor Lowther
On Wed, 2010-06-30 at 23:57 +0200, Thomas Bächler wrote:
 Nice patch, but ...
 
  -if [ -t 1 ]; then
  +if [[ -t 1 ]]; then
  SAVE_POSITION=\033[s
  RESTORE_POSITION=\033[u
  DEL_TEXT=\033[$(($STAT_COL+4))G
  @@ -116,10 +116,8 @@ stat_fail() {
 
 Hmm, this definitely doesn't belong into this patch.


Yeah, I think it got smashed together while I was rebasing things to
clean up.

   }
   
   stat_die() {
  -   retval=1
  -   [ $1 =  ] || retval=$1
  stat_fail
  -   exit $retval
  +   exit ${1:-1}
   }
   
   status() {
 
 Okay, this is certainly nicer than before.
 

-- 
Victor Lowther
LPIC2 UCP RHCE