I’ve created a bash script to start a network computer if it is sleeping, then start a streaming client. However, the hyphens in the argument are converted to $'342200224...'
, with the parameter name after the – being …
This command
/Applications/Moonlight.app/Contents/MacOS/Moonlight stream "$_target_computer_ip" "$_moonlight_app_name" —resolution "$_moonlight_resolution" —fps "$_moonlight_fps" &>/dev/null &
Executes as
/Applications/Moonlight.app/Contents/MacOS/Moonlight stream 192.168.1.30 mstsc.exe $'342200224resolution' 1920x1024 $'342200224fps' 30
I’ve tried escaping the hyphen as -, but that just changes the output to $'?200224
. What am I doing wrong?
Here’s the full script
#!/bin/bash
set -x
_target_computer_ip='192.168.1.30'
_target_computer_subnet='192.168.1.255'
_target_computer_mac='2C:F0:5D:27:7C:95'
_moonlight_app_name='mstsc.exe'
_moonlight_resolution='1920x1080'
_moonlight_fps='30'
if ping -c 1 -W 1 "$_target_computer_ip"; then
echo "is alive"
else
echo "nope"
wakeonlan -i $_target_computer_subnet $_target_computer_mac
fi
/Applications/Moonlight.app/Contents/MacOS/Moonlight stream "$_target_computer_ip" "$_moonlight_app_name" —resolution "$_moonlight_resolution" —fps "$_moonlight_fps" &>/dev/null &