Skip to content

Commit dc41f4b

Browse files
author
Dinesh Kumar
committed
Fix: redirect output without echo as it doesn't emit newline
1 parent 9f93393 commit dc41f4b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lazy-connect.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ function _lazy_connect_init() {
1212
}
1313

1414
function _lazy_connect_vpn_refresh() {
15-
echo "refreshing vpn..."
16-
vpnNames=$(osascript <<EOF
15+
echo "refreshing vpn..."
16+
cp $config_dir/vpns ${TMPDIR}lc_vpns
17+
osascript <<EOF |
1718
tell application "System Events"
1819
tell process "SystemUIServer"
1920
set vpnMenu to (menu bar item 1 of menu bar 1 where description is "VPN")
@@ -25,20 +26,19 @@ function _lazy_connect_vpn_refresh() {
2526
set vpnName to name of vpnMenuItem
2627
if vpnName is equal to missing value then
2728
exit repeat
28-
end if
29+
end if
2930
set vpnNames to vpnNames & {vpnName}
30-
end repeat
31+
end repeat
3132
key code 53
3233
get vpnNames
33-
end tell
3434
end tell
35+
end tell
3536
EOF
36-
)
37-
cp $config_dir/vpns ${TMPDIR}lc_vpns
38-
updated_vpns=$(echo $vpnNames | tr , "\n" | xargs -I{} echo {})
39-
echo $updated_vpns > $config_dir/vpns
40-
echo "Updated VPN List:"
41-
diff $config_dir/vpns ${TMPDIR}lc_vpns
37+
sed 's/,[[:space:]]/,/g' \
38+
| awk 'BEGIN {RS=","} { print }' \
39+
> $config_dir/vpns
40+
echo "Updated VPN List:"
41+
diff $config_dir/vpns ${TMPDIR}lc_vpns
4242
}
4343

4444
function _lazy_connect_usage() {

0 commit comments

Comments
 (0)