Skip to content

Instantly share code, notes, and snippets.

@dotysan
Created April 17, 2026 23:30
Show Gist options
  • Select an option

  • Save dotysan/6651c0a14bbeaddc18f7b91ed8ca7fd8 to your computer and use it in GitHub Desktop.

Select an option

Save dotysan/6651c0a14bbeaddc18f7b91ed8ca7fd8 to your computer and use it in GitHub Desktop.
The Rust AWK (rawk) fails to dedupe in some cases.
#! /usr/bin/env bash
#
# The Rust AWK (rawk) fails to dedupe in some cases.
# https://github.com/stefanalfbo/rawk/issues/19
#
INPUT=$(< test-input.txt)
PROG='
$1 !=prev {
print
prev= $1
}
'
main() {
gawk_dedupe_stdin # success
#rawk_dedupe_stdin # FAIL!/hang...
gawk_dedupe_redir # success
#rawk_dedupe_redir # FAIL!/hang...
gawk_dedupe_here_doc # success
#rawk_dedupe_here_doc # FAIL!/hang...
gawk_dedupe_here_str # success
#rawk_dedupe_here_str # FAIL!/hang...
gawk_dedupe_file # success
rawk_dedupe_file # success
gawk_dedupe_subst # success
rawk_dedupe_subst # success
}
gawk_dedupe_stdin() {
echo 'gawk reading from stdin:'
echo "$INPUT" |
gawk "$PROG"
}
rawk_dedupe_stdin() {
echo 'rawk reading from stdin:'
echo "$INPUT" |
rawk "$PROG"
}
gawk_dedupe_redir() {
echo 'gawk reading from a redirected file:'
gawk "$PROG" <test-input.txt
}
rawk_dedupe_redir() {
echo 'rawk reading from a redirected file:'
rawk "$PROG" <test-input.txt
}
gawk_dedupe_here_doc() {
echo 'gawk reading from here doc:'
gawk "$PROG" <<-EOF
$INPUT
EOF
}
rawk_dedupe_here_doc() {
echo 'rawk reading from here doc:'
rawk "$PROG" <<-EOF
$INPUT
EOF
}
gawk_dedupe_here_str() {
echo 'gawk reading from here string:'
gawk "$PROG" <<<"$INPUT"
}
rawk_dedupe_here_str() {
echo 'rawk reading from here string:'
rawk "$PROG" <<<"$INPUT"
}
gawk_dedupe_file() {
echo 'gawk reading from a file:'
gawk "$PROG" test-input.txt
}
rawk_dedupe_file() {
echo 'rawk reading from a file:'
rawk "$PROG" test-input.txt
}
gawk_dedupe_subst() {
echo 'gawk reading from process substitution:'
gawk "$PROG" <(< test-input.txt)
}
rawk_dedupe_subst() {
echo 'rawk reading from process substitution:'
rawk "$PROG" <(< test-input.txt)
}
main
exit $?
1
2
2
3
3
3
4
4
4
4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment