You are not logged in.

#1 2018-02-01 08:54:43

SpaceOttersea
Member
Registered: 2016-02-21
Posts: 11

Alias limiting rclone arguments

I've set up an alias in my bashrc to simplify my rclone commands for google drive. If I type the full command directly to the terminal, it runs just as expected. When I use the alias, however, I get an error: "Command sync needs 2 arguments maximum"

The relevant bit of my .bashrc looks looks like:

alias gdrive-up='rclone sync ~/Gdrive gdrive: --exclude '.*' -vu'
alias gdrive-dn='rclone sync gdrive: ~/Gdrive --exclude '.*' -vu'

I've used . ~/.bashrc and whatnot. I've even messed with adding and removing arguments, just to test. I'm really at a loss, here.
Thanks

Edit: Even if I copy the full command straight from .bashrc I get the error.

Last edited by SpaceOttersea (2018-02-01 08:55:41)

Offline

#2 2018-02-01 10:04:49

ayekat
Member
Registered: 2011-01-17
Posts: 1,634

Re: Alias limiting rclone arguments

The first step to troubleshooting issues with aliases is... displaying them!

alias gdrive-up gdrive-dn

And there you should already see where it goes wrong.
You are trying to nest single quotes within single quotes, which is not possible. Try quoting it as ".*" instead.

--edit: I also hope you now also understand why it's giving you that "too many arguments" error?

Last edited by ayekat (2018-02-01 10:06:34)


pkgs │ hacks │ cfg │ blag

Offline

#3 2018-02-01 11:45:08

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,396

Re: Alias limiting rclone arguments

Or rather remove the outer quotes, since the ~ will also not be correctly expanded otherwise.

Offline

#4 2018-02-01 12:21:18

ayekat
Member
Registered: 2011-01-17
Posts: 1,634

Re: Alias limiting rclone arguments

No, the outer quotes are required for alias definitions. See

alias a=b c
alias a

Also, the string is interpreted—and thus things like ~ and wildcards (e.g. .*) are resolved—by the shell the moment the alias is used, so that's not an issue. See:

alias a='echo ~'
a

pkgs │ hacks │ cfg │ blag

Offline

#5 2018-02-01 12:33:13

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,396

Re: Alias limiting rclone arguments

Ah true, sorry I brainfarted for a sec there.

Offline

#6 2018-02-01 15:59:27

SpaceOttersea
Member
Registered: 2016-02-21
Posts: 11

Re: Alias limiting rclone arguments

Oh, yep. Adding double quotes solved the issue. I'm new to scripting and all, but that does make sense. Thanks for the replies!

Offline

Board footer

Powered by FluxBB