Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error: invalid integer contant at line 445 #11

Open
grince opened this issue Sep 29, 2024 · 1 comment
Open

Error: invalid integer contant at line 445 #11

grince opened this issue Sep 29, 2024 · 1 comment

Comments

@grince
Copy link

grince commented Sep 29, 2024

I just downloaded that wonderful bash-script for this wonderful idea.

I am running Debian 12, installed jq and jq2a additionally.
but when I try to start the script without any parameter (so, a random oil painting should be shown), I receive the following:

$./aic.sh
./aic.sh: line 445: 16#: invalid integer constant (error token is "16#")
Bacchic Revels, c. 1740
Johann Georg Platzer (Austrian, 1704–1761)
https://www.artic.edu/artworks/46383/bacchic-revels

this happens also a second time:
$./aic.sh
./aic.sh: line 445: 16#: invalid integer constant (error token is "16#")
Queen Philippa at the Battle of Neville's Cross, c. 1789
Benjamin West (British, born United States, 1738–1820)
https://www.artic.edu/artworks/57652/queen-philippa-at-the-battle-of-neville-s-cross

@evilham
Copy link

evilham commented Oct 31, 2024

Hey, I also wanted to test this and ran against this issue.

It looks like there are a couple issues, one is that sometimes the row consists of <pre, which produces this particular error.

Once we get past that, the regex is not prepared to handle &nbsp;, so it passes a lot of <span style=...>&nbsp;</span> down the road producing the same issue inconsistently.

Here is a quick patch I prepared to play with things :-)
Note that I replace &nbsp; with "U+202F   NARROW NO-BREAK SPACE".

diff --git a/aic.sh b/aic.sh
index 755d7bd..424b546 100755
--- a/aic.sh
+++ b/aic.sh
@@ -390,11 +390,16 @@ if [ ! "$OPT_FILL" = '--fill' ]; then
         for ROW in "${ROWS[@]}"; do
 
             # Transform spans into space-separated quadruples of R G B [Char], using pipes as span-separators
-            ROW="$(echo "$ROW" | sed -E "s/<span style='color:#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2});'>(.)<\/span>/\1 \2 \3 \4|/g")"
+           ROW="$(echo "$ROW" | sed -E -e "s/&nbsp;/ /g" -e "s/<span style='color:#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2});'>(.)<\/span>/\1 \2 \3 \4|/g")"
 
             # Discard the last pipe
             ROW="${ROW::-1}"
 
+           if [ "$ROW" = "<pre" ]; then
+                   continue;
+           fi
+
+
             # Split row into columns using pipes
             while IFS='|' read -ra COLS; do
                 for COL in "${COLS[@]}"; do
@@ -429,11 +434,15 @@ else
         for ROW in "${ROWS[@]}"; do
 
             # Transform spans into space-separated quadruples of R G B [Char], using pipes as span-separators
-            ROW="$(echo "$ROW" | sed -E "s/<span style='color:#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2}); background-color:#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2});'>(.)<\/span>/\1 \2 \3 \4 \5 \6 \7|/g")"
+           ROW="$(echo "$ROW" | sed -E -e "s/&nbsp;/ /g" -e "s/<span style='color:#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2}); background-color:#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2});'>(.)<\/span>/\1 \2 \3 \4 \5 \6 \7|/g")"
 
             # Discard the last pipe
             ROW="${ROW::-1}"
 
+           if [ "$ROW" = "<pre" ]; then
+                   continue;
+           fi
+
             # Split row into columns using pipes
             while IFS='|' read -ra COLS; do
                 for COL in "${COLS[@]}"; do

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants