引用の仕方が分からない

引用の仕方が分からない

こんにちは。私は bash とコーディング全般についてまったくの初心者です。実行したい画面コマンドがあります。私はすでに画面「ftb」で Minecraft コンソールを実行しています。

screen -S ftb -p 0 -X stuff "tellraw @p ["",{"text":"This is a text!","bold":true,"color":"gold"},{"text":"\n"},{"text":"More text to be seen here!"},{"text":"\n"},{"text":"HAVE SOME TEXT IN UR FACE!","color":"green","clickEvent":{"action":"open_url","value":"https://google.com"}},{"text":"\n"},{"text":"Have Fun!"}]"

しかし、コマンドは引用符で囲まれて混乱します。これまでこれを試してみましたが、うまくいきませんでした...

#! /bin/sh

say_this()

{
        screen -S ftb -p 0 -X stuff "$1^M"
}

say_this "tellraw @p ["",{"text":"This is a text!","bold":true,"color":"gold"},{"text":"\n"},{"text":"More text to be seen here!"},{"text":"\n"},{"text":"HAVE SOME TEXT IN UR FACE!","color":"green","clickEvent":{"action":"open_url","value":"https://google.com"}},{"text":"\n"},{"text":"Have Fun!"}]"

Minecraft コンソールで実行したいコマンドをカプセル化して、画面がすべての引用符を無視し、コマンド全体を「ftb」画面の Minecraft コンソールに送信して実行する方法はありますか?

このコマンドはコンソールに記述して実行する必要があります。

tellraw @p ["",{"text":"This is a text!","bold":true,"color":"gold"},{"text":"\n"},{"text":"More text to be seen here!"},{"text":"\n"},{"text":"HAVE SOME TEXT IN UR FACE!","color":"green","clickEvent":{"action":"open_url","value":"https://google.com"}},{"text":"\n"},{"text":"Have Fun!"}]

答え1

これはシェルのもので、screen物ではありません。全体を一重引用符で囲む必要があります。一重引用符内の唯一の特殊文字は一重引用符です (引用符を終了します)。

したがって、これは

say_this 'message'

例えば

say_this 'tellraw @p ["",{"text":"This is a text!","bold":true,"color":"gold"},{"text":"\n"},{"text":"More text to be seen here!"},{"text":"\n"},{"text":"HAVE SOME TEXT IN UR FACE!","color":"green","clickEvent":{"action":"open_url","value":"https://google.com"}},{"text":"\n"},{"text":"Have Fun!"}]'

関連情報