Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (1984ea17c887f36c63f3051b030e2874ca475abc)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Jaka Kranjc <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (1984ea17c887f36c63f3051b030e2874ca475abc)
  • Date: Thu, 15 Sep 2011 06:02:23 -0500

GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:

ChangeLog | 6 ++++++
usr/sbin/cabal | 19 -------------------
usr/sbin/gaze | 15 +--------------
usr/sbin/sorcery | 20 --------------------
var/lib/sorcery/modules/libmisc | 34 ++++++++++++++++++++++++++++++++++
5 files changed, 41 insertions(+), 53 deletions(-)

New commits:
commit 1984ea17c887f36c63f3051b030e2874ca475abc
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

merged display_file into show_file

commit 90157201df88ccd1fbc93c93d8e8a4b72a8370d6
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

merged show_file from cabal and sorcery

commit 096d673a6926cec4c4aa6cb807dd245bebca2234
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

libmisc: added xz and 7z support to display_file

commit 1ed1844ded4f88fc523a41821587bc696e30bd07
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

gaze, sorcery, cabal: merged a similar file display function

diff --git a/ChangeLog b/ChangeLog
index cc2ab79..2a206b3 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-09-15 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * gaze, sorcery, cabal: merged a similar file display function
+ * libmisc: added xz and 7z support to display_file
+ merged show_file from cabal and sorcery
+ merged display_file into show_file
+
2011-09-14 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* config: unset GREP_OPTIONS in case the user set it to something bad
* libstage: ensure the install log is sorted #33
diff --git a/usr/sbin/cabal b/usr/sbin/cabal
index dd0eebd..c056a7b 100755
--- a/usr/sbin/cabal
+++ b/usr/sbin/cabal
@@ -535,25 +535,6 @@ function cabal_menu() {

}

-function show_file() {
-
- if [ -f $1 ]; then
-
- if [ "`file -b $1 | cut -d ' ' -f1`" == "bzip2" ]; then
- bzcat $1 | $PAGER
- elif [ "`file -b $1 | cut -d ' ' -f1`" == "gzip" ]; then
- gzip -cd $1 | $PAGER
- else
- eval $DIALOG '--textbox $1 0 0'
- fi
-
- else
- eval $DIALOG '--msgbox "File not found." 0 0'
- return 1
- fi
-
-}
-
. /etc/sorcery/config

if [ -n "${PAGER}" ]
diff --git a/usr/sbin/gaze b/usr/sbin/gaze
index 4c756ba..8b579f6 100755
--- a/usr/sbin/gaze
+++ b/usr/sbin/gaze
@@ -579,20 +579,7 @@ function gaze_catalog_html() {
#-----
function display() {
local file=$(FUZZ=on guess_filename "$1")
-
- if [[ -s $file ]]; then
- case "$(file -b "$file")" in
- *text) cat "$file" | $PAGER ;;
- bzip2*) bzcat "$file" | $PAGER ;;
- gzip*) gzip -cd "$file" | $PAGER ;;
- *) message "Unknown file type."
- return 1 ;;
- esac
- else
- message "$2" 1>&2
- false
- fi
-
+ show_file "$file" no "$2"
}

#-----
diff --git a/usr/sbin/sorcery b/usr/sbin/sorcery
index 6cb8401..4b4f30d 100755
--- a/usr/sbin/sorcery
+++ b/usr/sbin/sorcery
@@ -244,26 +244,6 @@ add_pkgs() { (
) }


-show_file() {
-
- if [ -f $1 ]; then
-
- if [ "`file -b $1 | cut -d ' ' -f1`" == "bzip2" ]; then
- bzcat $1 | $PAGER
- elif [ "`file -b $1 | cut -d ' ' -f1`" == "gzip" ]; then
- gzip -cd $1 | $PAGER
- else
- eval $DIALOG '--textbox $1 0 0'
- fi
-
- else
- eval $DIALOG '--msgbox "File not found." 0 0'
- return 1
- fi
-
-}
-
-
file_list() {

LIST=`ls $1`
diff --git a/var/lib/sorcery/modules/libmisc b/var/lib/sorcery/modules/libmisc
index 7a49f0a..37ec1e7 100755
--- a/var/lib/sorcery/modules/libmisc
+++ b/var/lib/sorcery/modules/libmisc
@@ -1603,6 +1603,40 @@ function get_failure_reason() {
upvar $_upvar "$_reason"
}

+#---------------------------------------------------------------------
+## Checks if the file is compressed and displays it
+##
+## @param file
+## @param use dialog (optional)
+## @param message to print on error (optional)
+#---------------------------------------------------------------------
+function show_file() {
+ local file=$1
+ local dialog=${2:-yes}
+ local msg=${3:-"File not found."}
+ if [[ -f $file && -s $file ]]; then
+ case "$(file -b "$file")" in
+ *text) if [[ $dialog ]]; then
+ eval $DIALOG '--textbox $1 0 0'
+ else
+ cat "$file" | $PAGER
+ fi ;;
+ bzip2*) bzcat "$file" | $PAGER ;;
+ gzip*) gzip -cd "$file" | $PAGER ;;
+ XZ*) xz -cd "$file" | $PAGER ;;
+ 7-zip*) 7z -d "$file" | $PAGER ;;
+ *) message "Unknown file type."
+ return 1 ;;
+ esac
+ else
+ if [[ $dialog == yes ]]; then
+ eval $DIALOG '--msgbox "'$msg'" 0 0'
+ else
+ message "$msg" 1>&2
+ fi
+ return 1
+ fi
+}

# Standard debug line:
# file "function@line" "all" "args"



  • [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (1984ea17c887f36c63f3051b030e2874ca475abc), Jaka Kranjc, 09/15/2011

Archive powered by MHonArc 2.6.24.

Top of Page