Commit 5bebf3c9 authored by Dominik Gabi's avatar Dominik Gabi Committed by Facebook Github Bot

move `shellQuote` to implementation file

Summary: Fixing ODR violations...

Reviewed By: simpkins, yfeldblum

Differential Revision: D3875667

fbshipit-source-id: 0d8ec0b48e14fffb7e3e60c0e68e2576b2f58d1e
parent d9749c81
...@@ -468,6 +468,7 @@ libfolly_la_SOURCES = \ ...@@ -468,6 +468,7 @@ libfolly_la_SOURCES = \
Random.cpp \ Random.cpp \
SafeAssert.cpp \ SafeAssert.cpp \
SharedMutex.cpp \ SharedMutex.cpp \
Shell.cpp \
MicroLock.cpp \ MicroLock.cpp \
Singleton.cpp \ Singleton.cpp \
SocketAddress.cpp \ SocketAddress.cpp \
......
/*
* 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 <folly/Shell.h>
namespace folly {
std::string shellQuote(StringPiece argument) {
std::string quoted = "'";
for (auto c : argument) {
if (c == '\'') {
quoted += "'\\''";
} else {
quoted += c;
}
}
return quoted + "'";
}
} // folly
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <folly/Conv.h>
#include <folly/Format.h> #include <folly/Format.h>
#include <folly/Range.h> #include <folly/Range.h>
...@@ -35,17 +36,7 @@ namespace folly { ...@@ -35,17 +36,7 @@ namespace folly {
/** /**
* Quotes an argument to make it suitable for use as shell command arguments. * Quotes an argument to make it suitable for use as shell command arguments.
*/ */
std::string shellQuote(StringPiece argument) { std::string shellQuote(StringPiece argument);
std::string quoted = "'";
for (auto c : argument) {
if (c == '\'') {
quoted += "'\\''";
} else {
quoted += c;
}
}
return quoted + "'";
}
/** /**
* Create argument array for `Subprocess()` for a process running in a * Create argument array for `Subprocess()` for a process running in a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment