From 5bebf3c9ea5276ce8a099bcce9a3dfa9c6727bb8 Mon Sep 17 00:00:00 2001 From: Dominik Gabi Date: Fri, 16 Sep 2016 15:00:45 -0700 Subject: [PATCH] move `shellQuote` to implementation file Summary: Fixing ODR violations... Reviewed By: simpkins, yfeldblum Differential Revision: D3875667 fbshipit-source-id: 0d8ec0b48e14fffb7e3e60c0e68e2576b2f58d1e --- folly/Makefile.am | 1 + folly/Shell.cpp | 33 +++++++++++++++++++++++++++++++++ folly/Shell.h | 13 ++----------- 3 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 folly/Shell.cpp diff --git a/folly/Makefile.am b/folly/Makefile.am index 5a5f66ab..d1cdf4bd 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -468,6 +468,7 @@ libfolly_la_SOURCES = \ Random.cpp \ SafeAssert.cpp \ SharedMutex.cpp \ + Shell.cpp \ MicroLock.cpp \ Singleton.cpp \ SocketAddress.cpp \ diff --git a/folly/Shell.cpp b/folly/Shell.cpp new file mode 100644 index 00000000..f9c626b4 --- /dev/null +++ b/folly/Shell.cpp @@ -0,0 +1,33 @@ +/* + * Copyright 2016 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +namespace folly { + +std::string shellQuote(StringPiece argument) { + std::string quoted = "'"; + for (auto c : argument) { + if (c == '\'') { + quoted += "'\\''"; + } else { + quoted += c; + } + } + return quoted + "'"; +} + +} // folly diff --git a/folly/Shell.h b/folly/Shell.h index c7aca9b7..f7009c04 100644 --- a/folly/Shell.h +++ b/folly/Shell.h @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -35,17 +36,7 @@ namespace folly { /** * Quotes an argument to make it suitable for use as shell command arguments. */ -std::string shellQuote(StringPiece argument) { - std::string quoted = "'"; - for (auto c : argument) { - if (c == '\'') { - quoted += "'\\''"; - } else { - quoted += c; - } - } - return quoted + "'"; -} +std::string shellQuote(StringPiece argument); /** * Create argument array for `Subprocess()` for a process running in a -- 2.34.1