Flags order confuses the command line in lxd export

lxc export c1 --instance-only --optimized-storage --compression=bzip2 --project testing

works fine.

However the order of the options generates different error messages:

lxc export nc-env-vm --instance-only --optimized-storage --compression --project testing
Error: Create instance backup: Instance not found
$ lxc export nc-env-vm --instance-only --optimized-storage --project testing --compression
Error: flag needs an argument: --compression

Of course, latter is the proper error reported.

So there is an issue here, happy to report it if needed.

Also, question: is there a compulsory order between flags and global flags? Can I put a flag after a global flag?

What LXD version is that on?

Here I’m getting:

stgraber@castiana:~$ lxc export test --instance-only --optimized-storage --compression --project default
Error: Create backup: exec: "--project": executable file not found in $PATH

Which actually kinda makes sense as it parses:

  • arg0 => test (instance name)
  • instance-only => flag without value
  • optimized-storage => flag without value
  • compression => flag with value, taking the next arg as value (--project)
  • arg1 => default

So it effectively processes this request as: Export instance name with instance-only and optimized-storage set, using compression algorithm --target and export that to a file called default.

It’s a weird request but not an invalid one. Someone really odd could have a compressor tool on their system named --project :wink:

Thanks for your reply.

So, flags with value can be with = or not, right?

I’m on 5.13.