I'm running a Linux subsystem on a Windows 10 machine. I wrote a script to download the latest build from a Jenkins server, renamed it, and saved it on the Onedrive mapped in Windows. The problem is those spaces and the dash in the path are not handled well when running the script.
The script is the one below:
#!/bin/bash
path=$(echo "OneDrive - Atos")
echo $path
echo "/mnt/c/Users/A474998/$xpath/"
filename=$(echo "\"/mnt/c/Users/A474998/$path/___Software/SIP_CP100.img\"")
echo $filename
curl http://jenkins.devices-dev.global-intra.net/view/mainline/job/we1_cp100_sip_arm_nightly/lastStableBuild/artifact/vobs/Opera_Build/Nightly/SIP/WP_LO_CP100/cruise/opera_bind.SIP.WP_LO.nand.img --output $filename
This is the output when I run the script
bokos@DESKTOP-DLETB9D:~$ ./testget
OneDrive - Atos
/mnt/c/Users/A474998//
"/mnt/c/Users/A474998/OneDrive - Atos/___Software/SIP_CP100.img"
curl: option -: is unknown
curl: try 'curl --help' or 'curl --manual' for more information

I run this script in debug mode and this is the output
bokos@DESKTOP-DLETB9D:~$ sh -x ./testget
+ echo OneDrive - Atos
+ path=OneDrive - Atos
+ echo OneDrive - Atos
OneDrive - Atos
+ echo /mnt/c/Users/A474998//
/mnt/c/Users/A474998//
+ echo "/mnt/c/Users/A474998/OneDrive - Atos/___Software/SIP_CP100.img"
+ filename="/mnt/c/Users/A474998/OneDrive - Atos/___Software/SIP_CP100.img"
+ echo "/mnt/c/Users/A474998/OneDrive - Atos/___Software/SIP_CP100.img"
"/mnt/c/Users/A474998/OneDrive - Atos/___Software/SIP_CP100.img"
+ curl http://jenkins.devices-dev.global-intra.net/view/mainline/job/we1_cp100_sip_arm_nightly/lastStableBuild/artifact/vobs/Opera_Build/Nightly/SIP/WP_LO_CP100/cruise/opera_bind.SIP.WP_LO.nand.img --output "/mnt/c/Users/A474998/OneDrive - Atos/___Software/SIP_CP100.img"
curl: option -: is unknown
curl: try 'curl --help' or 'curl --manual' for more information

If I manually run the command from the debug mode I can download the file and save it in the correct Onedrive location
bokos@DESKTOP-DLETB9D:~$ curl http://jenkins.devices-dev.global-intra.net/view/mainline/job/we1_cp100_sip_arm_nightly/lastStableBuild/artifact/vobs/Opera_Build/Nightly/SIP/WP_LO_CP100/cruise/opera_bind.SIP.WP_LO.nand.img --output "/mnt/c/Users/A474998/OneDrive - Atos/___Software/SIP_CP100.img"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 22.2M 100 22.2M 0 0 747k 0 0:00:30 0:00:30 --:--:-- 470k

I then copy this command in a script
#!/bin/bash
curl http://jenkins.devices-dev.global-intra.net/view/mainline/job/we1_cp100_sip_arm_nightly/lastStableBuild/artifact/vobs/Opera_Build/Nightly/SIP/WP_LO_CP100/cruise/opera_bind.SIP.WP_LO.nand.img --output "/mnt/c/Users/A474998/OneDrive - Atos/___Software/SIP_CP100.img"
and when I execute it, the file will be downloaded and saved in the correct location
bokos@DESKTOP-DLETB9D:~$ ./testget
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 22.2M 100 22.2M 0 0 790k 0 0:00:28 0:00:28 --:--:-- 868k

I have tried lots of combinations with
" " ' ' ``
I cannot rename the path of Onedrive to remove space and dash. So I m really confused and I don't know what I m doing wrong. Any help will be appreciated. Thank you for your time in advance.