mirror of
https://github.com/rclone/rclone.git
synced 2025-01-24 12:56:36 +02:00
3c4407442d
The previous behavior of the remotes completion was that only alphanumeric characters were allowed in a remote name. This limitation has been lifted somewhat by #2985, which also allowed an underscore. With the new implementation introduced in this commit, the completion of the remote name has been simplified: If there is no colon (":") in the current word, then complete remote name. Otherwise, complete the path inside the specified remote. This allows correct completion of all remote names that are allowed by the config (including - and _). Actually it matches much more than that, even remote names that are not allowed by the config, but in such a case there already would be a wrong identifier in the configuration file. With this simpler string comparison, we can get rid of the regular expression, which makes the completion multiple times faster. For a sample benchmark, try the following: # Old way $ time bash -c 'for _ in {1..1000000}; do [[ remote:path =~ ^[[:alnum:]]*$ ]]; done' real 0m15,637s user 0m15,613s sys 0m0,024s # New way $ time bash -c 'for _ in {1..1000000}; do [[ remote:path != *:* ]]; done' real 0m1,324s user 0m1,304s sys 0m0,020s