This is an automated email from the git hooks/post-receive script.

roam-guest pushed a commit to branch master
in repository fenix.

commit a04f12a19e0f175c99fab8def71c5702a23a5cf4
Author: Peter Pentchev <[email protected]>
Date:   Thu Dec 17 18:14:58 2015 +0200

    Refresh the debian/fenix.sh script a bit.
---
 debian/changelog |  1 +
 debian/fenix.sh  | 63 ++++++++++++++++++++++++++++++--------------------------
 2 files changed, 35 insertions(+), 29 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 05ec507..ec44fbe 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,7 @@ fenix (0.92a.dfsg1-12) UNRELEASED; urgency=medium
   * Fix the encoding of the Spanish translation.  Closes: #684279.
     Reported by: Jakub Wilk <[email protected]>
     Submitted by: Christian PERRIER <[email protected]>
+  * Refresh the debian/fenix.sh script a bit.
 
  -- Peter Pentchev <[email protected]>  Thu, 17 Dec 2015 16:11:53 +0200
 
diff --git a/debian/fenix.sh b/debian/fenix.sh
index 245c52c..7384fea 100755
--- a/debian/fenix.sh
+++ b/debian/fenix.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 # (c) 2007 Miriam Ruiz <[email protected]>
+# (c) 2015 Peter Pentchev <[email protected]>
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -19,52 +20,56 @@
 ARG="$1"
 GAME_FILE=""
 
-if [ -z "$GAME_FILE" ] && [ -z "$ARG" ]; then
-       FILE_NUM=`ls *.prg 2>/dev/null | wc -l`
-       if [ "$FILE_NUM" -eq 1 ] ; then
-               GAME_FILE=`ls *.prg 2>/dev/null`
-       else
-               GAME_FILE=""
+tempf=`mktemp -t fenix.XXXXXX`
+trap "rm -f -- '$tempf'" EXIT HUP INT QUIT TERM
+
+single_file() {
+       local dir="$1"
+
+       local count=0
+       if [ -d "$dir" ] && [ -r "$dir" ]; then
+               find -- "$dir" -mindepth 1 -maxdepth 1 -type f -name '*.prg' > 
"$tempf"
+               count=`wc -l < "$tempf"`
        fi
+       if [ "$count" -eq 1 ]; then
+               cat -- "$tempf"
+       fi
+}
+
+if [ -z "$GAME_FILE" ] && [ -z "$ARG" ]; then
+       GAME_FILE=`single_file '.'`
 fi
 
 if [ -z "$GAME_FILE" ] && [ -d "$ARG" ]; then
-       FILE_NUM=`ls "$ARG"/*.prg 2>/dev/null | wc -l`
-       if [ "$FILE_NUM" -eq 1 ] ; then
-               GAME_FILE=`ls "$ARG"/*.prg` 2>/dev/null
-       else
-               GAME_FILE=""
+       GAME_FILE=`single_file "$ARG"`
+       if [ -z "$GAME_FILE" ]; then
                echo "Cannot choose a game file in the directory \"$ARG\"" >&2
                exit 1
        fi
 fi
 
-if [ -z "$GAME_FILE" ] && [ -e "$ARG" ]; then
-       FILE_NUM=`ls "$ARG" 2>/dev/null | wc -l`
-       if [ "$FILE_NUM" -eq 1 ] ; then
-               GAME_FILE="$ARG"
-       else
-               GAME_FILE=""
-               echo "Cannot choose a game file" >&2
-       fi
-fi
-
-if [ -z "$GAME_FILE" ] && [ ! -z "$ARG" ] && [ -z "$2" ]; then
-       echo "Game program does not exist in \"$ARG\"" >&2
-       exit 1
+if [ -z "$GAME_FILE" ] && [ -f "$ARG" ]; then
+       GAME_FILE="$ARG"
 fi
 
-if [ -z "$GAME_FILE" ] || [ ! -z "$2" ]; then
-       echo "Usage: $0" >&2
-       echo "Usage: $0 <file.prg>" >&2
-       echo "Usage: $0 <directory>" >&2
+if [ -z "$GAME_FILE" ]; then
+       if [ "$#" -eq 1 ]; then
+               echo "Game program does not exist in \"$ARG\"" >&2
+       else
+               echo "Usage: $0" >&2
+               echo "Usage: $0 <file.prg>" >&2
+               echo "Usage: $0 <directory>" >&2
+       fi
        exit 1
 fi
 
-if [ -z "$GAME_FILE" ] || [ ! -e "$GAME_FILE" ]; then
+if [ ! -f "$GAME_FILE" ]; then
        echo "File \"$GAME_FILE\" does not exist" >&2
        exit 1
 fi
 
+rm -f -- "$tempf"
+trap '' EXIT HUP INT QUIT TERM
+
 echo "Game File: \"$GAME_FILE\"" >&2
 fenix-fxc "$GAME_FILE" -o - | fenix-fxi -t "$GAME_FILE" -

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/fenix.git

_______________________________________________
Pkg-games-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to