summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libalpine.sh.in30
-rw-r--r--setup-apkrepos.in4
-rw-r--r--setup-disk.in28
-rw-r--r--setup-interfaces.in16
-rw-r--r--setup-keymap.in2
-rw-r--r--setup-mta.in2
-rw-r--r--setup-proxy.in6
7 files changed, 40 insertions, 48 deletions
diff --git a/libalpine.sh.in b/libalpine.sh.in
index 0215c4d..43f5385 100644
--- a/libalpine.sh.in
+++ b/libalpine.sh.in
@@ -8,22 +8,6 @@ PROGRAM=$(basename $0)
[ "${ROOT}" = "${ROOT%/}" ] && ROOT="${ROOT}/"
[ "${ROOT}" = "${ROOT#/}" ] && ROOT="${PWD}/${ROOT}"
-echon () {
- if [ X"$ECHON" = X ]; then
- # Determine how to "echo" without newline: "echo -n"
- # or "echo ...\c"
- if [ X$(echo -n) = X-n ]; then
- ECHON=echo
- NNL="\c"
- # "
- else
- ECHON="echo -n"
- NNL=""
- fi
- fi
- $ECHON "$*$NNL"
-}
-
# echo if in verbose mode
vecho() {
if [ -n "$VERBOSE" ]; then
@@ -110,7 +94,7 @@ available_ifaces() {
sorted_ifindexes=$(
for i in "$ROOT"/sys/class/net/*/ifindex; do
[ -e "$i" ] || continue
- echo -e "$(cat $i)\t$i";
+ printf "%s\t%s\n" "$(cat $i)" $i;
done | sort -n | awk '{print $2}')
for i in $sorted_ifindexes; do
ifpath=${i%/*}
@@ -132,7 +116,7 @@ available_ifaces() {
# *Don't* echo input.
# *Don't* interpret "\" as escape character.
askpass() {
- echo -n "$1 "
+ printf %s "$1 "
set -o noglob
$MOCK stty -echo
read -r resp
@@ -176,7 +160,7 @@ rmel() {
shift
for _b; do
- [ "$_a" != "$_b" ] && echo -n "$_b "
+ [ "$_a" != "$_b" ] && printf %s "$_b "
done
}
@@ -210,8 +194,8 @@ ask() {
local _question=$1 _default=$2
while :; do
- echo -n "$_question "
- [ -z "$_default" ] || echo -n "[$_default] "
+ printf %s "$_question "
+ [ -z "$_default" ] || printf "[%s] " "$_default"
_ask && : ${resp:=$_default} && break
done
}
@@ -275,8 +259,8 @@ ask_which() {
: ${_dyndef:=$1}
echo "Available ${_name}s are: $_dynlist."
- echo -n "Which one $_query? (or 'done') "
- [ -n "$_dyndef" ] && echo -n "[$_dyndef] "
+ printf "Which one %s? (or 'done') " "$_query"
+ [ -n "$_dyndef" ] && printf "[%s] " "$_dyndef"
_ask || continue
[ -z "$resp" ] && resp="$_dyndef"
diff --git a/setup-apkrepos.in b/setup-apkrepos.in
index 1367476..488a9f0 100644
--- a/setup-apkrepos.in
+++ b/setup-apkrepos.in
@@ -30,7 +30,7 @@ add_random_mirror() {
local i=0
local random_mirror_index=$(( $RANDOM % $mirror_count ))
- echo -n "Picking random mirror... "
+ printf %s "Picking random mirror... "
for mirror in $MIRRORS; do
if [ $i -eq $random_mirror_index ]; then
break
@@ -225,7 +225,7 @@ while ! $changed; do
done
if $changed; then
- echo -n "Updating repository indexes... "
+ printf %s "Updating repository indexes... "
$MOCK apk update --quiet $apk_root_opt && echo "done."
fi
diff --git a/setup-disk.in b/setup-disk.in
index 7e87f2a..fb383d8 100644
--- a/setup-disk.in
+++ b/setup-disk.in
@@ -73,7 +73,8 @@ enumerate_fstab() {
else
fs_passno=2
fi
- echo -e "$(uuid_or_device $fs_spec)\t${fs_file}\t${fs_vfstype}\t${fs_mntops} ${fs_freq} ${fs_passno}"
+ printf "%s\t%s\t%s\t%s %s %s\n" \
+ "$(uuid_or_device $fs_spec)" "$fs_file" "$fs_vfstype" "$fs_mntops" $fs_freq $fs_passno
done
}
@@ -212,7 +213,7 @@ unpack_apkovl() {
fi
local count=0
# beep
- echo -e "\007"
+ printf "\007"
while [ $count -lt 3 ]; do
openssl enc -d -$suffix -in "$ovl" | tar --numeric-owner \
-C "$dest" -zxv >$ovlfiles 2>/dev/null && return 0
@@ -590,7 +591,8 @@ install_mounted_root() {
if [ -n "$SWAP_DEVICES" ]; then
local swap_dev
for swap_dev in $SWAP_DEVICES; do
- echo -e "$(uuid_or_device ${swap_dev})\tswap\tswap\tdefaults\t0 0" \
+ printf "%s\tswap\tswap\tdefaults\t0 0\n" \
+ "$(uuid_or_device $swap_dev)" \
>> "$mnt"/etc/fstab
done
fi
@@ -772,7 +774,7 @@ find_disks() {
local p=
# filter out ramdisks (major=1)
for p in $(awk '$1 != 1 && $1 ~ /[0-9]+/ {print $4}' /proc/partitions); do
- is_available_disk $p && echo -n " $p"
+ is_available_disk $p && printf %s " $p"
done
}
@@ -971,7 +973,7 @@ setup_lvm_volume_group() {
fi
if [ -n "$USE_CRYPT" ] && [ "$DISK_MODE" = "data" ]; then
- echo -e "target=var\nsource='$lvmdev'" > /etc/conf.d/dmcrypt
+ printf "target=var\nsource='%s'\n" "$lvmdev" > /etc/conf.d/dmcrypt
lvmdev=$(setup_crypt $lvmdev var) || return 1
rc-update add dmcrypt boot
fi
@@ -993,7 +995,8 @@ setup_swap_dev() {
SWAP_DEVICES=
for swap_dev in "$@"; do
mkswap $swap_dev >/dev/null
- echo -e "$(uuid_or_device $swap_dev)\tswap\t\tswap\tdefaults 0 0" >> /etc/fstab
+ printf "%s\tswap\t\tswap\tdefaults 0 0\n" \
+ "$(uuid_or_device $swap_dev)" >> /etc/fstab
SWAP_DEVICES="$SWAP_DEVICES $swap_dev"
done
swapon -a
@@ -1026,7 +1029,8 @@ setup_var() {
echo "Creating file systems..."
mkfs.$varfs $MKFS_OPTS_VAR $var_dev >/dev/null || return 1
sed -i -e '/[[:space:]]\/var[[:space:]]/d' /etc/fstab
- echo -e "$(uuid_or_device ${var_dev})\t/var\t\t${varfs}\tdefaults 1 2" >> /etc/fstab
+ printf "%s\t/var\t\t%s\tdefaults 1 2\n" \
+ "$(uuid_or_device $var_dev)" "$varfs" >> /etc/fstab
mv /var /.var
mkdir /var
@@ -1120,7 +1124,7 @@ data_only_disk_install() {
fi
if [ -n "$USE_CRYPT" ]; then
- echo -e "target=var\nsource='$var_dev'" > /etc/conf.d/dmcrypt
+ printf "target=var\nsource='%s'\n" "$var_dev" > /etc/conf.d/dmcrypt
var_dev=$(setup_crypt $var_dev var) || return 1
rc-update add dmcrypt boot
fi
@@ -1566,10 +1570,10 @@ if [ -n "$diskdevs" ] && [ -z "$DISK_MODE" ]; then
fi
while true; do
- echo -n "The following $disk_is_or_disks_are selected"
- [ -n "$USE_CRYPT" ] && [ -z "$USE_LVM" ] && echo -n " (with encryption)"
- [ -z "$USE_CRYPT" ] && [ -n "$USE_LVM" ] && echo -n " (with LVM)"
- [ -n "$USE_CRYPT" ] && [ -n "$USE_LVM" ] && echo -n " (with LVM on LUKS)"
+ printf "The following %s selected" "$disk_is_or_disks_are"
+ [ -n "$USE_CRYPT" ] && [ -z "$USE_LVM" ] && printf %s " (with encryption)"
+ [ -z "$USE_CRYPT" ] && [ -n "$USE_LVM" ] && printf %s " (with LVM)"
+ [ -n "$USE_CRYPT" ] && [ -n "$USE_LVM" ] && printf %s " (with LVM on LUKS)"
echo ":"
show_disk_info $diskdevs
_crypt=$([ -z "$USE_CRYPT" ] && [ -z "$USE_LVM" ] && echo ", 'crypt'")
diff --git a/setup-interfaces.in b/setup-interfaces.in
index 4a7078c..35cc8d6 100644
--- a/setup-interfaces.in
+++ b/setup-interfaces.in
@@ -496,14 +496,14 @@ prompt_for_interfaces() {
echo "iface $iface inet $type" >> interfaces
if [ -n "$bridge_ports" ]; then
PKGS="$PKGS bridge"
- echo -e "\tbridge-ports $bridge_ports" >> interfaces
+ printf "\tbridge-ports %s\n" "$bridge_ports" >> interfaces
fi
if [ -n "$bond_slaves" ]; then
PKGS="$PKGS bonding"
- echo -e "\tbond-slaves $bond_slaves" >> interfaces
+ printf "\tbond-slaves %s\n" "$bond_slaves" >> interfaces
fi
if [ -n "$raw_device" ]; then
- echo -e "\tvlan-raw-device $raw_device" >> interfaces
+ printf "\tvlan-raw-device %s\n" "$raw_device" >> interfaces
fi
case "$iface" in
*.[0-9]*|vlan[0-9]*)
@@ -514,14 +514,14 @@ prompt_for_interfaces() {
esac
case $type in
manual)
- echo -e "\tup ip link set \$IFACE up" >> interfaces
- echo -e "\tdown ip link set \$IFACE down" >> interfaces
+ printf "\tup ip link set \$IFACE up\n" >> interfaces
+ printf "\tdown ip link set \$IFACE down\n" >> interfaces
;;
static)
- echo -e "\taddress $address" >> interfaces
- echo -e "\tnetmask $netmask" >> interfaces
+ printf "\taddress %s\n" "$address" >> interfaces
+ printf "\tnetmask %s\n" "$netmask" >> interfaces
[ "$gateway" ] \
- && echo -e "\tgateway $gateway" >> interfaces
+ && printf "\tgateway %s\n" "$gateway" >> interfaces
;;
esac
echo "" >> interfaces
diff --git a/setup-keymap.in b/setup-keymap.in
index bb4f55d..2ada75f 100644
--- a/setup-keymap.in
+++ b/setup-keymap.in
@@ -79,7 +79,7 @@ setup_mapfile() {
select_variant() {
while true; do
- echon "Available variants: "
+ printf %s "Available variants: "
show_variants "$layout"
if [ ! -f "$MAPDIR/$layout/$variant.bmap" ] ; then
variant=""
diff --git a/setup-mta.in b/setup-mta.in
index eaea499..3758d5c 100644
--- a/setup-mta.in
+++ b/setup-mta.in
@@ -64,7 +64,7 @@ while [ $# -eq 0 ] && [ "$res" != "221" ]; do
if ! ask_yesno "Test connection? (y/n)" y; then
break
fi
- res=$(echo -e "quit\r\n" | nc $mailhub 25 | awk '/^221/ {print $1}')
+ res=$(printf "quit\r\n\n" | nc $mailhub 25 | awk '/^221/ {print $1}')
[ "x$res" = "x221" ] && echo "Connection to $mailhub is ok."
done
diff --git a/setup-proxy.in b/setup-proxy.in
index 0c1d14c..70522d1 100644
--- a/setup-proxy.in
+++ b/setup-proxy.in
@@ -64,5 +64,9 @@ else
fi
if [ -z "$quiet" ] && [ "$proxyurl" != "none" ]; then
- echo -e "\nTo make changes active please do login again or source $PROFILE\nwith \". $PROFILE\""
+ cat <<-__EOF__
+
+ To make changes active please do login again or source $PROFILE
+ with ". $PROFILE"
+ __EOF__
fi