From 56384e572d419a48439a90b9481a715a13a109c8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 5 Jan 2014 17:09:11 -0500 Subject: src/lib/: set TEXTDOMAIN differently for internal messages This allows us to fix the long-standing bug that libremessages forces TEXTDOMAIN=libretools --- src/lib/libremessages.1.ronn | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/lib/libremessages.1.ronn') diff --git a/src/lib/libremessages.1.ronn b/src/lib/libremessages.1.ronn index b91a958..30314c8 100644 --- a/src/lib/libremessages.1.ronn +++ b/src/lib/libremessages.1.ronn @@ -188,12 +188,6 @@ These routines relate to `makepkg`(8). ## BUGS -libremessages sets to `libretools` unconditionally, -making it generally unsuitable for use outside of libretools. If you -override after loading the library, that should work, but -you will also have to provide translations for libremessage's internal -messages (such as "ERROR" or "Warning"). - Generating `.pot` files for the prose functions is a pain. The libretools Makefiles have rules to do it, but it might make sense to pull it into a separate program. -- cgit v1.2.3-54-g00ecf From ca879723bef3b0f638a2e6262f1fc869cf2b14be Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 18 Jan 2014 12:47:01 -0500 Subject: Update libremessages.1.ronn --- src/lib/libremessages.1.ronn | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/lib/libremessages.1.ronn') diff --git a/src/lib/libremessages.1.ronn b/src/lib/libremessages.1.ronn index 30314c8..bf052bd 100644 --- a/src/lib/libremessages.1.ronn +++ b/src/lib/libremessages.1.ronn @@ -104,7 +104,7 @@ For each of these, is fed through `gettext` automatically. These routines print to standard error, and all take arguments in the same format as `printf`(1), except for `stat_done`, which doesn't take -any arguments. +any arguments. Each of these print to stderr, not stdout. For each of these, is fed through `gettext` automatically. @@ -178,6 +178,13 @@ these, you could end up deleting a lot of someone's work. These routines relate to `makepkg`(8). + * `find_cached_package` [-: + Searches for a localy built copy of the specified package, in + and the current working directory. If is not + specified, any value will match. If multiple matching files are + found (not counting duplicate links), then an error is printed to + stderr and nothing is prented to stdout. + * `get_full_version` []: Inspects variables that are set, and prints the full version spec, including if necessary, , and . By -- cgit v1.2.3-54-g00ecf From 63362d52d3943f40fb96898a2b4e87e17f0adcf4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 20 Jan 2014 00:43:09 -0500 Subject: libremessages: add a setup_traps routine --- src/lib/libremessages | 19 +++++++++++++++++++ src/lib/libremessages.1.ronn | 4 ++++ 2 files changed, 23 insertions(+) (limited to 'src/lib/libremessages.1.ronn') diff --git a/src/lib/libremessages b/src/lib/libremessages index 8e48c3b..df0a98a 100755 --- a/src/lib/libremessages +++ b/src/lib/libremessages @@ -117,6 +117,25 @@ term_title() { printf "$fmt" "$*" } +# Usage: setup_traps +# Sets up traps on TERM, HUP, QUIT and INT signals, as well as the ERR event, +# similar to makepkg +setup_traps() { + _libremessages_trap_exit() { + local signal=$1; shift + echo + error "$@" + trap -- "$signal" + kill "-$signal" "$$" + } + set -E + for signal in TERM HUP QUIT; do + trap "_libremessages_trap_exit $signal '%s signal caught. Exiting...' $signal" $signal + done + trap '_libremessages_trap_exit INT "Aborted by user! Exiting..."' INT + trap '_libremessages_trap_exit USR1 "An unknown error has occurred. Exiting..."' ERR +} + ################################################################################ # Run one of the defined functions if invoked directly # ################################################################################ diff --git a/src/lib/libremessages.1.ronn b/src/lib/libremessages.1.ronn index bf052bd..d4c35fc 100644 --- a/src/lib/libremessages.1.ronn +++ b/src/lib/libremessages.1.ronn @@ -69,6 +69,10 @@ Unless otherwise noted, these do not implicitly call `gettext`. Joins all arguments with whitespace, and sets the terminal title to that. + * `setup_traps`: + Sets traps on TERM, HUP, QUIT and INT signals, as sell as the ERR + event, similar to makepkg. + ### PROSE ROUTINES These routines print to standard output, ande are useful for printing -- cgit v1.2.3-54-g00ecf From 74f68d0149f2a94780c860b0775d1e880dbe9225 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 5 Mar 2014 10:57:57 -0500 Subject: teach libremessages:setup_traps to be able to use a custom signal handler --- src/lib/libremessages | 31 ++++++++++++++++++++++--------- src/lib/libremessages.1.ronn | 9 +++++++-- 2 files changed, 29 insertions(+), 11 deletions(-) (limited to 'src/lib/libremessages.1.ronn') diff --git a/src/lib/libremessages b/src/lib/libremessages index e5b7157..162c8fb 100755 --- a/src/lib/libremessages +++ b/src/lib/libremessages @@ -117,17 +117,30 @@ term_title() { printf "$fmt" "$*" } -# Usage: setup_traps +# Usage: setup_traps [handler] # Sets up traps on TERM, HUP, QUIT and INT signals, as well as the ERR event, -# similar to makepkg +# similar to makepkg. +# +# If `handler` is specified, instead of using the default handler +# (which is good for most purposes), it will call the command handler +# with the arguments: +# +# ${handler} SIGNAL_NAME MESSAGE_FMT [MESSAGE_PARAMS...] +# +# where MESSAGE_* are printf-like stuff. setup_traps() { - _libremessages_trap_exit() { - local signal=$1; shift - echo - error "$@" - trap -- "$signal" - kill "-$signal" "$$" - } + [[ $# -le 1 ]] || panic + if [[ $# == 1 ]]; then + eval "_libremessages_trap_exit() { $1 \"\$@\"; }" + else + _libremessages_trap_exit() { + local signal=$1; shift + echo + error "$@" + trap -- "$signal" + kill "-$signal" "$$" + } + fi set -E for signal in TERM HUP QUIT; do trap "_libremessages_trap_exit $signal '%s signal caught. Exiting...' $signal" $signal diff --git a/src/lib/libremessages.1.ronn b/src/lib/libremessages.1.ronn index d4c35fc..d39dad0 100644 --- a/src/lib/libremessages.1.ronn +++ b/src/lib/libremessages.1.ronn @@ -69,9 +69,14 @@ Unless otherwise noted, these do not implicitly call `gettext`. Joins all arguments with whitespace, and sets the terminal title to that. - * `setup_traps`: + * `setup_traps` []: Sets traps on TERM, HUP, QUIT and INT signals, as sell as the ERR - event, similar to makepkg. + event, similar to makepkg. If is specified, instead of + using the default handler (which is good for most purposes), it + will call with the arguments + ` [...]`, where + is a `printf`(1)-formatted string, and + are its arguments. ### PROSE ROUTINES -- cgit v1.2.3-54-g00ecf From 9f1ef0bbdf1bc246c0c035a2dd6a4bcfa41664ef Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 11 May 2014 23:31:58 -0400 Subject: update the libremessages man page with changes from devtools --- src/lib/libremessages.1.ronn | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/lib/libremessages.1.ronn') diff --git a/src/lib/libremessages.1.ronn b/src/lib/libremessages.1.ronn index d39dad0..2bf73a1 100644 --- a/src/lib/libremessages.1.ronn +++ b/src/lib/libremessages.1.ronn @@ -156,15 +156,16 @@ these, you could end up deleting a lot of someone's work. * `cleanup` []: *If* `setup_workdir` has been run, `rm -rf "$WORKDIR"`. If given - a numeric argument, it will then call `exit`(1) with that argument. + a numeric argument, it will then call `exit`(1) with that + argument, otherwise it calls `exit`(1) with a status of 0. * `abort`: Calls `msg` with the message "Aborting...", then calls - `cleanup 0`. + `cleanup 255`. * `die` [...]: Exactly like `error`, but calls `cleanup` and calls `exit`(1) - with a status of 1. + with a status of 255. ### LOCKFILE ROUTINES @@ -212,9 +213,6 @@ pull it into a separate program. xterm and rxvt (and their various values; "rxvt-unicode-256color" is still rxvt). -Also, I think `abort` calling `cleanup 1` would make more sense than -`cleanup 0`. - ## SEE ALSO librelib(7), gettext(1), common.sh(3) -- cgit v1.2.3-54-g00ecf