一种方法为prevent的bash从解析命令行瓦特/使用转义符号 [英] A way to prevent bash from parsing command line w/out using escape symbols

查看:119
本文介绍了一种方法为prevent的bash从解析命令行瓦特/使用转义符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一种方式(除。,'。',\\)来使用bash(或任何其它Linux的shell),而$ P $从解析命令行的部分pventing它。这个问题似乎是无法解决
<一href=\"http://stackoverflow.com/questions/14922730/how-to-inter$p$pt-special-characters-in-command-line-argument-in-c/14924332#14924332\">How在用C命令行参数间preT特殊字符?

I'm looking for a way (other than ".", '.', \.) to use bash (or any other linux shell) while preventing it from parsing parts of command line. The problem seems to be unsolvable How to interpret special characters in command line argument in C?

在理论上,一个简单的开关就足够了(例如-x ...告诉该
串...不会间preTED),但它显然不存在。我不知道是否有解决办法,黑客或想法解决这个问题。最初的问题是一个脚本|为((其可包含特殊字符&放大器;等))作为参数的程序采取YouTube网址别名。这个问题就更加困难:扩大$ 1,而从国际$ P $ preventing外壳pting的扩展字符串 - 本质上,拓展$ 1不跨preting它的结果。

In theory, a simple switch would suffice (e.g. -x ... telling that the string ... won't be interpreted) but it apparently doesn't exist. I wonder whether there is a workaround, hack or idea for solving this problem. The original problem is a script|alias for a program taking youtube URLs (which may contain special characters (&, etc.)) as arguments. This problem is even more difficult: expanding "$1" while preventing shell from interpreting the expanded string -- essentially, expanding "$1" without interpreting its result

推荐答案

使用一个这里文档

myprogramm <<'EOF'
https://www.youtube.com/watch?v=oT3mCybbhf0
EOF

如果您缠绕开始 EOF 在单引号,bash将不会跨preT在这里-doc的任何特殊字符。

If you wrap the starting EOF in single quotes, bash won't interpret any special chars in the here-doc.

这篇关于一种方法为prevent的bash从解析命令行瓦特/使用转义符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆