[CLOSED] howto use awk inside Woof-CE EXTRA_COMMANDS?

interpretive language scripts


Moderator: Forum moderators

Post Reply
User avatar
peebee
Posts: 1636
Joined: Mon Jul 13, 2020 10:54 am
Location: Worcestershire, UK
Has thanked: 157 times
Been thanked: 714 times
Contact:

[CLOSED] howto use awk inside Woof-CE EXTRA_COMMANDS?

Post by peebee »

CLOSED - solution provided by JamesBond - many thanks.

I want to add some code into the EXTRA_COMMANDS of Woof-CE 3builddistro to make a mime entry in freedesktop.xml have different extensions.

i.e I want to change .m3u & .m3u8 at lines 21 & 22 of cut-freedesktop.xml to
.xm3u and .xm3u8

I have been experimenting with using awk.

The file awk.sh.txt shows at line 7 an awk command that does the trick if called directly in a terminal
awk -i inplace '/m3u/{c+=1}{if(c==6 || c==7){sub("m3u","xm3u",$0)};print}' cut-freedesktop.org.xml

but the same code (+ some escapes) at lines 2 & 3 does not work ( sh awk.sh.txt )..... and this is how it would need to be embedded in EXTRA_COMMANDS....

Grateful if anybody can suggest coding that will work when embedded - thanks.

Attachments
cut-freedesktop.org.xml
(1.02 KiB) Downloaded 18 times
awk.sh.txt
(364 Bytes) Downloaded 21 times

Builder of LxPups, SPups, UPup32s, VoidPups; LXDE, LXQt, Xfce addons; Chromium, Firefox etc. sfs; & Kernels

jamesbond
Posts: 717
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 124 times
Been thanked: 402 times

Re: howto use awk inside Woof-CE EXTRA_COMMANDS?

Post by jamesbond »

You forgot to quote $0.
Should \$0 instead of $0 on line 2.
But why do it this way? Why not just use shell functions instead of eval?

User avatar
peebee
Posts: 1636
Joined: Mon Jul 13, 2020 10:54 am
Location: Worcestershire, UK
Has thanked: 157 times
Been thanked: 714 times
Contact:

Re: howto use awk inside Woof-CE EXTRA_COMMANDS?

Post by peebee »

jamesbond wrote: Fri Mar 01, 2024 7:18 pm

You forgot to quote $0.
Should \$0 instead of $0 on line 2.
But why do it this way? Why not just use shell functions instead of eval?

Many thanks JB...... this is how Woof-CE 3builddistro actions the EXTRA_COMMANDS in _00build.conf

Builder of LxPups, SPups, UPup32s, VoidPups; LXDE, LXQt, Xfce addons; Chromium, Firefox etc. sfs; & Kernels

dimkr
Posts: 2423
Joined: Wed Dec 30, 2020 6:14 pm
Has thanked: 53 times
Been thanked: 1202 times

Re: howto use awk inside Woof-CE EXTRA_COMMANDS?

Post by dimkr »

It would be easier to replace this horrible EXTRA_COMMANDS thing with an optional script that runs at the end of the build, so no eval and escaping is needed.

Post Reply

Return to “Scripts”