add a makepkg dlagent, which accept a non zero exit code

190 views Asked by At

For some downloads lgogdownloader return always the exit code 141 after a successful download. Because of this the dlagent should catch this exit code.

I have already try some dlagents, but non of this works:

DLAGENTS+=('gogdownloader::/usr/bin/lgogdownloader --download-file=%u -o %o || /usr/bin/test $? -eq 141')

Error: unrecognised option '-eq'
DLAGENTS+=('gogdownloader::/usr/bin/bash -c \"lgogdownloader --download-file=%u -o %o || test $? -eq 141\"')

--download-file=gogdownloader://2146639313/en3installer0: -c: line 0: unexpected EOF while looking for matching `"'
--download-file=gogdownloader://2146639313/en3installer0: -c: line 1: syntax error: unexpected end of file

2

There are 2 answers

2
msrd0 On

Your problem is that you incorrectly escape the " inside a ' string. This reproduces your 2nd error message:

$ eval '/usr/bin/bash -c \"echo hello world\"'
hello: -c: line 0: unexpected EOF while looking for matching `"'
hello: -c: line 1: syntax error: unexpected end of file

The 1st occurence of \" is treated as that literal sequence, while the 2nd occurence escapes the quotation, leaving you with an never-ending string. Removing the escape, you get the desired result:

$ eval '/usr/bin/bash -c "echo hello world"'
hello world
0
LuckyTurtleDev On

How msrd0 has mention you can use a separate script:

DLAGENTS+=("gogdownloader::./catch_gogdownloader_error141.sh %u %o")
#!/bin/bash
lgogdownloader --download-file=$1 -o $2 || test $? -eq 141

But I think this is more a workaround than a real solution.