How to concatenate strings in Shell
Hello, I'm trying to create a wrapper script around texttops filter in CUPS. The original texttops accepts 6 arguments:
texttops $job-id $user $title $copies $options $file
The fifth argument are user options passed true lp command (lp -o landscape -o cpi=15).The problem is, that the fifth argument arrives to texttops like concatenated strings:
"landscape cpi=15 lpi=12"
In my wrapper script, I'm changing some of this options, but when I'm trying to pass them to texttops, it does not accept them as one string. Here what I've done so far:
#!/bin/ksh
options="5"
eval set -A opt "$options" # array
for opt in ${opt[@]}; do
case $opt in
landscape)
add="foo"
;;
lpi=*)
add="bar"
;;
esac
newoptions=$add" "$newoptions
done
( eval texttops $job-id $user $title $copies "$newoptions" $file )
The problem is, that $newoptions is not recognised like one string but like several, and when I'm trying to pass them to texttops, it returns an error. The script returns something like this (7 arguments, instead of 6):
texttops 1 root no-title 1 landscape lpi=12 /tmp/file-to-print
The "landscape" and "lpi" are not recognised as one string, so texttops assumes that "lpi=12" is the name of the file.
Any ideas, how to concatenate newoptions, so it will be recognised as one string?
|