Using BusyBox shell, sed can't parse regex

#!/bin/sh
emoji="\U1f300-\U1f5ff\U1f900-\U1f9ff\U1f600-\U1f64f\U1f680-\U1f6ff\U2600-\U26ff\U2700-\U27bf\U1f1e6-\U1f1ff\U1f191-\U1f251\U1f004\U1f0cf\U1f170-\U1f171\U1f17e-\U1f17f\U1f18e\U3030\U2b50\U2b55\U2934-\U2935\U2b05-\U2b07\U2b1b-\U2b1c\U3297\U3299\U303d\U00a9\U00ae\U2122\U23f3\U24c2\U23e9-\U23ef\U25b6\U23f8-\U23fa"
sample="This 🍒 is ⭐ a 🐢 line 🤮 of 😃 emoji ✈"
echo $sample
echo $sample | LC_ALL=UTF-8 sed -e "s/[$(printf $emoji)]//g"

The preceding script can obtain normal execution results on other Linux operating systems (such as centos). However, if the script is executed on OpenWRT, an error message is displayed sed: bad regex Invalid character range or the correct result cannot be obtained after execution. Attempts were made to change the sed version to 4.8 but the problem persisted. Is this bash or is the system environment incomplete?

If it is a system shell environment problem, but the following script can get normal results

grep -Pv '[\x{1f300}-\x{1f5ff}\x{1f900}-\x{1f9ff}\x{1f600}-\x{1f64f}\x{1f680}-\x{1f6ff}\x{2600}-\x{26ff}\x{2700}-\x{27bf}\x{1f1e6}-\x{1f1ff}\x{1f191}-\x{1f251}\x{1f004}\x{1f0cf}\x{1f170}-\x{1f171}\x{1f17e}-\x{1f17f}\x{1f18e}\x{3030}\x{2b50}\x{2b55}\x{2934}-\x{2935}\x{2b05}-\x{2b07}\x{2b1b}-\x{2b1c}\x{3297}\x{3299}\x{303d}\x{00a9}\x{00ae}\x{2122}\x{23f3}\x{24c2}\x{23e9}-\x{23ef}\x{25b6}\x{23f8}-\x{23fa}]'

While I understand this was tested in openwrt, what is the practical consequence or concern here? There are very few circumstances where emoji would be relevant in openwrt operation.

Do you mean that this problem is caused by the incomplete system environment itself?

I mean, under what circumstances would you actually need sed to be able to parse emojis in OpenWrt. It's not like they're found in the config files.

I'm sorry. Don't know what you're talking about?

1 Like

I'll ask another way.

Why do you need (within the context of a running OpenWrt system) to parse emojis?

There are emoji characters in the APP profile that need to be replaced! In addition, I feel that your question is very strange, can not say that OpenWRT does not meet the need, after all, other Linxu systems have no problems!

1 Like

What app profile?

OpenWrt is not a general purpose operating system.

1 Like

What APP is not the point of my question! My question is why the same script gets results correctly on other Linux but not OpenWRT. If it is a problem with the sed version, my upgrade to the sed version still has no effect. If the OpenWRT environment does not support emoji issues, but the following grep can run normally.

grep -Pv '[\x{1f300}-\x{1f5ff}\x{1f900}-\x{1f9ff}\x{1f600}-\x{1f64f}\x{1f680}-\x{1f6ff}\x{2600}-\x{26ff}\x{2700}-\x{27bf}\x{1f1e6}-\x{1f1ff}\x{1f191}-\x{1f251}\x{1f004}\x{1f0cf}\x{1f170}-\x{1f171}\x{1f17e}-\x{1f17f}\x{1f18e}\x{3030}\x{2b50}\x{2b55}\x{2934}-\x{2935}\x{2b05}-\x{2b07}\x{2b1b}-\x{2b1c}\x{3297}\x{3299}\x{303d}\x{00a9}\x{00ae}\x{2122}\x{23f3}\x{24c2}\x{23e9}-\x{23ef}\x{25b6}\x{23f8}-\x{23fa}]'

It is generally relevant, yes. I am not aware of any "app profile" that affects OpenWrt. What are you talking about here so that we can address the need?

What version of OpenWrt are you running?

ubus call system board

I don't think this has anything to do with the app! openwrt 21.02

1 Like

What is the output of

And what is this app? Where does it run? What does it do?

1 Like

The requirement is to use a script to replace all the emoji characters in the text, how do you do that?

Why are you so reluctant to answer the direct questions?

ubus call system board

And what is the app?

2 Likes

Because there is no sense, this has nothing to do with the question, thank you for your answer! I think it's better to see if other people have effective suggestions!

1 Like

This version is EOL and unsupported. I've been asking for the output of the ubus command to understand if you have options to use a more recent version.

Your refusal to answer the basic questions with any clarity leads me to believe that you are not running official OpenWrt. Further, your mysterious app is probably outside the realm of supportability given that there is no such "app profile" with OpenWrt, nor is there any environment within OpenWrt where one would expect to encounter emojis.

I suspect that you're not going to get any better answers unless you are willing to be more forthcoming with the requested information.

EDIT: It's also worth pointing out that you know that 21.02 is no longer supported -- you asked about support timeframes in a thread just over 6 months ago

2 Likes

Perhaps it is the problem of language translation, I think you have not understood my description. In addition, I believe the new version of OpenWRT will have the same problem! So our communication is ineffective.

1 Like

It is quite simple, really. Issue this command and show us the output:

ubus call system board

And tell us what openwrt app is expecting emoji.

I have very effective suggestion - be very effective and without hesiatation or curtsy discussion post output of

ubus call system board
opkg search `which sed`
1 Like

ubus call system board

{
        "kernel": "5.4.179",
        "hostname": "***",
        "system": "Atheros AR9344",
        "model": "***",
        "board_name": "***",
        "release": {
                "distribution": "OpenWrt",
                "version": "21.02.2",
                "revision": "r16495-bf0c965af0",
                "target": "ath79/nand",
                "description": "OpenWrt 21.02.2 r16495-bf0c965af0"
        }
}

opkg search which sed

busybox - 1.33.2-2

Some information that I think is not important and private is hidden. In addition, I used opkg install sed to update to version 4.8, but now it has no effect to restore to the original state