Hello,
Your script presents a practice that I warned you against recently.Below is a corrected version.
this topic is not about URL sanitization , the problem was a flaw in the options passed to wget2. So your post is rather off topic.I have a script that does something like this to sanitize urls...
Your script presents a practice that I warned you against recently.
Code:
$> lsplip plop$> ARR=( $(sed 's/a/A/g' <<<"abc p*p abc") )$> declare -p ARR declare -a ARR=([0]="Abc" [1]="plip" [2]="plop" [3]="Abc")
Code:
#!/usr/bin/env bash### use 'read -rp' if you want to keep backslashesread -p "paste url and enter:" arg### avoids echo, and cut is not necessary.#URL="$(sed 's/?.*$//' <<<"$arg")"### sed is not necessary either, Bash is enough#URL="${arg%%\?*}"### unquoted expressions can give unexpected and potentially dangerous results.### Use read -ra to split on the IFS, do not remove the quotes.read -ra ARR < <(sed -E 's|https?://([^/]+)/(.*)/([^/]+)/?$|\1 \2 \3|' <<<"${arg%%\?*}")
Statistics: Posted by fabien — 2024-05-25 00:49 — Replies 11 — Views 588