aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorfelics2018-05-22 11:54:47 +0200
committerfelics2018-05-22 11:54:47 +0200
commit5af5f3737893d566054e712178eccda747e721b4 (patch)
treeb6166475319077f4cba5f321cb24e834d43904e2
parent3281962e67887388d1612b66cd714e2a9dd01a22 (diff)
downloadaur-5af5f3737893d566054e712178eccda747e721b4.tar.gz
Added arbitrary environment variables via Device URI
-rw-r--r--.SRCINFO10
-rw-r--r--PKGBUILD8
-rw-r--r--README.md6
-rwxr-xr-xcups-programme.sh26
4 files changed, 37 insertions, 13 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 1902b62a46ed..d52e966404b5 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = cups-print-to-programme
pkgdesc = Virtual printer for cups which prints to a file and opens that with a programme the user can choose in the settings. For example, print to gimp.
- pkgver = 0.1.6
- pkgrel = 3
+ pkgver = 0.2
+ pkgrel = 1
url = http://felics.kettenbruch.de/software/cups-print-to-programme/
install = cups-programme.install
arch = any
@@ -20,7 +20,7 @@ pkgbase = cups-print-to-programme
optdepends = seahorse: For a graphical password input frontend for sudo.
optdepends = ksshaskpass: For a graphical password input frontend for sudo.
optdepends = gnome-ssh-askpass2: For a graphical password input frontend for sudo.
- provides = cups-print-to-programme-doc=0.1.6
+ provides = cups-print-to-programme-doc=0.2
backup = etc/cups/cups-programme.conf
source = cups-programme.sh
source = cups-programme.conf
@@ -28,9 +28,9 @@ pkgbase = cups-print-to-programme
source = TODO.txt
source = GPL3.txt
source = cups-programme.install
- sha256sums = eddbf1398da6052d5dba15e84f82e20e81c87c8dd0a69222ba818c05d8babd1f
+ sha256sums = bd63ca00ad98880f529c3f53594c0dca0d683bb40a111b1356fa7d19bad04363
sha256sums = f583ed8969deef9e890b20c475bc24fd4eed8ef3c3a51544f9183fcc69d38c5c
- sha256sums = fff96ebdac583c710fa8762e967929b905ed342a0b8977268741e40403a3e31c
+ sha256sums = a8f2e7e2b796d19b21b91c5224274397eb35a39616d4caf7ed612d19b32a9768
sha256sums = 83b54a69c67d39d03b1b02a4da1c2bccb45c459f239809568221844c2e7500a7
sha256sums = 3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986
sha256sums = 0ee996783ae6848cf3c522de135646cb4b19670a48d6f1bf387b5b304f5506ad
diff --git a/PKGBUILD b/PKGBUILD
index 120133bfa3b4..7eaeba63e112 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,8 +3,8 @@
_pkgname=cups-print-to-programme
pkgname="${_pkgname}"
-pkgver=0.1.6
-pkgrel=3
+pkgver=0.2
+pkgrel=1
pkgdesc="Virtual printer for cups which prints to a file and opens that with a programme the user can choose in the settings. For example, print to gimp."
arch=('any')
depends=(
@@ -38,9 +38,9 @@ optdepends=(
)
provides=("${_pkgname}-doc=${pkgver}")
backup=('etc/cups/cups-programme.conf')
-sha256sums=('eddbf1398da6052d5dba15e84f82e20e81c87c8dd0a69222ba818c05d8babd1f'
+sha256sums=('bd63ca00ad98880f529c3f53594c0dca0d683bb40a111b1356fa7d19bad04363'
'f583ed8969deef9e890b20c475bc24fd4eed8ef3c3a51544f9183fcc69d38c5c'
- 'fff96ebdac583c710fa8762e967929b905ed342a0b8977268741e40403a3e31c'
+ 'a8f2e7e2b796d19b21b91c5224274397eb35a39616d4caf7ed612d19b32a9768'
'83b54a69c67d39d03b1b02a4da1c2bccb45c459f239809568221844c2e7500a7'
'3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986'
'0ee996783ae6848cf3c522de135646cb4b19670a48d6f1bf387b5b304f5506ad')
diff --git a/README.md b/README.md
index 51bc65f7c8ac..0c531bffd0dc 100644
--- a/README.md
+++ b/README.md
@@ -133,7 +133,13 @@ where:
- `%C` -> `:`,
- `%T` -> `'`,
- `%G` -> `"`,
+ - `%E` -> `=`,
+ - `%M` -> `@`,
- `%%` -> `%`.
+ These replacements are carried out after cups-programme has parsed the
+ Device URI, so e.g. `%E` can be used to escape a `=` from
+ cups-programme's parser, e.g. to pass `u=...` as argument to the
+ executable.
Configuration File
diff --git a/cups-programme.sh b/cups-programme.sh
index b5ef5e27d49f..48a55645be20 100755
--- a/cups-programme.sh
+++ b/cups-programme.sh
@@ -29,7 +29,7 @@
#
# The version.
-VERSION=0.1.6
+VERSION=0.2
# Abort on error
set -e
@@ -229,9 +229,13 @@ log_local ""
# - '%C' -> ':'
# - '%T' -> '''
# - '%G' -> '"'
+# - '%E' -> '='
+# - '%M' -> '@'
# - '%%' -> '%'
# - '%s' -> "${outfile}" (The, probably converted, output from CUPS to
# open)
+# The replacements will be carried out after we have parsed the options,
+# so '%E' can be used to escape a '=' from our parser.
#
# The programme will be invoked with the specified arguments.
@@ -250,11 +254,9 @@ unset user
unset group
unset display
unset filetype
+env_vars=()
# Have this as function that we will call, so that we can make use of 'shift'.
parse_argv() {
- replace_strings() {
- cat | replace '%%' '%' '%.' ' ' '%_' '-' '%P' '|' '%B' '\' '%H' '#' '%Q' '?' '%A' '&' '%C' ':' '%G' '"' '%T' "'" '%s' "${outfile}"
- }
while [ $# -gt 0 ]; do
_arg="$1"
case "${_arg}" in
@@ -277,6 +279,10 @@ parse_argv() {
filetype="${_arg#t=}"
log_local " Parsed 't='-option. filetype: '${filetype}'."
;;
+ ?*=*)
+ env_vars+=("${_arg}")
+ log_local " Parsed variable assignment '${_arg}'."
+ ;;
*)
arg="${_arg}"
log_local " Parsed next argument. It is: '${arg}'."
@@ -300,6 +306,9 @@ fi
outfile="${outfile_prefix}.${filetype}"
# Now, after $outfile is set, do the string replacements:
+replace_strings() {
+ replace '%%' '%' '%.' ' ' '%_' '-' '%P' '|' '%B' '\' '%H' '#' '%Q' '?' '%A' '&' '%C' ':' '%G' '"' '%T' "'" '%E' '=' '%M' '@' '%s' "${outfile}"
+}
if [ -v cmd ]; then cmd="$(echo "${cmd}" | replace_strings)"; fi
if [ -v user ]; then user="$(echo "${user}" | replace_strings)"; fi
if [ -v group ]; then group="$(echo "${group}" | replace_strings)"; fi
@@ -308,6 +317,15 @@ cmd_args_replaced=()
for _arg in "${cmd_args[@]}"; do
cmd_args_replaced+=("$(echo "${_arg}" | replace_strings)")
done
+# Exporting environment variables after replacements.
+for _env in "${env_vars[@]}"; do
+ _var="$(echo "${_env%%=*}" | replace_strings)")
+ _val="$(echo "${_env#?*=}" | replace_strings)")
+ log_local "Exporting environment variable '${_var}=${_val}'."
+ declare -g "${_var}=${_val}"
+ export "${_var}"
+done
+log_local ""