[arch-projects] [netctl][PATCH] Automatically escape dashes in interface names

Ivan Shapovalov intelfx100 at gmail.com
Tue Feb 12 07:39:09 EST 2013


Custom interface names like "eth-phone" or "eth-lte" are not uncommon,
and since they are used in pathes inside systemd units, dashes and unprintable
characters shall be escaped per unit file rules.

So replace "-" with "\x2d" in interface names.
---
 src/netctl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/netctl b/src/netctl
index 7cf0b59..498b50d 100755
--- a/src/netctl
+++ b/src/netctl
@@ -89,6 +89,7 @@ unit_enable() {
     echo -e "\n[Unit]" >> "$unit"
     [[ -n $Description ]] && echo "Description=$Description" >> "$unit"
     : ${BindsToInterfaces=$Interface}
+    BindsToInterfaces=( "${BindsToInterfaces[@]/-/\\x2d}" )
     printf 'BindsTo=sys-subsystem-net-devices-%s.device\n' \
            "${BindsToInterfaces[@]}" >> "$unit"
     printf 'After=sys-subsystem-net-devices-%s.device\n' \
-- 
1.8.1.3




More information about the arch-projects mailing list