From 36b81324ae450ea065865ef75cf789ef0d36d9cf Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 12 Feb 2020 20:47:12 +0800 Subject: 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 --- src/common/ceph_argparse.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common/ceph_argparse.cc') 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& 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, -- cgit v1.2.3