我有一个脚本 mount-gdrive-encrypted.command :
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
rclone mount gdrive-encrypted:/ /Users/John/Documents/Mount -vv
当我双击执行该脚本时:
Last login: Sun Jul 14 12:52:28 on ttys001
Johns-MacBook-Air:~ John$ /Users/John/Documents/mount-gdrive-encrypted.command ; exit;
2019/07/14 12:52:41 DEBUG : rclone: Version "v1.47.0" starting with parameters ["rclone" "mount" "gdrive-encrypted:/\u00a0/Users/John/Documents/Mount" "-vv"]
Command mount needs 2 arguments minimum: you provided 1 non flag arguments: ["gdrive-encrypted:/\u00a0/Users/John/Documents/Mount"]
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
\u00a0
似乎是在运行时添加的,这导致rclone认为我的源和目标是一个字符串而不是两个字符串。
我尝试用这种方式替换它,但是没有运气:
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
cmd="rclone mount gdrive-encrypted:/ /Users/John/Documents/Mount -vv"
cmd="${cmd//\u00a0/ }"
eval $cmd
手动运行时,rclone命令有效。如何更改我的脚本以阻止添加该非空格空间?