diff options
author | Kefu Chai <kchai@redhat.com> | 2020-02-12 13:47:12 +0100 |
---|---|---|
committer | Kefu Chai <kchai@redhat.com> | 2020-02-12 15:18:30 +0100 |
commit | 36b81324ae450ea065865ef75cf789ef0d36d9cf (patch) | |
tree | 34dcb158e530f6730a400230478ae6a78486ee15 /src/common/ceph_argparse.cc | |
parent | ceph_argparse: refactor env_to_vec() (diff) | |
download | ceph-36b81324ae450ea065865ef75cf789ef0d36d9cf.tar.xz ceph-36b81324ae450ea065865ef75cf789ef0d36d9cf.zip |
ceph_argparse: put args from env before existing ones
to ensure environment variables can be overriden by command line
arguments.
For example, if you have "CEPH_ARGS='--id XYZ'", passing "--id ABC" to
a Ceph CLI tool should result in the ABC id being utilized.
Fixes: https://tracker.ceph.com/issues/43795
Signed-off-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'src/common/ceph_argparse.cc')
-rw-r--r-- | src/common/ceph_argparse.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/ceph_argparse.cc b/src/common/ceph_argparse.cc index 73272e554b4..631bc7c5470 100644 --- a/src/common/ceph_argparse.cc +++ b/src/common/ceph_argparse.cc @@ -117,14 +117,14 @@ void env_to_vec(std::vector<const char*>& args, const char *name) auto [env_options, env_arguments] = split_dashdash(env); args.clear(); - args.insert(args.end(), options.begin(), options.end()); args.insert(args.end(), env_options.begin(), env_options.end()); + args.insert(args.end(), options.begin(), options.end()); if (arguments.empty() && env_arguments.empty()) { return; } args.push_back("--"); - args.insert(args.end(), arguments.begin(), arguments.end()); args.insert(args.end(), env_arguments.begin(), env_arguments.end()); + args.insert(args.end(), arguments.begin(), arguments.end()); } void argv_to_vec(int argc, const char **argv, |