Skip to content

Commit

Permalink
calendar: fix error with non-gnu awk
Browse files Browse the repository at this point in the history
Use the POSIX-specified function Awk keyword instead of the non-standard
func to define the prepare function in the text/calendar filter.

The GNU Awk manual[1] mentions that gawk supports abbreviating function
to func, but recommends against using the func abbreviation, as POSIX
only specifies function.

On my system (Debian sid), gawk isn't installed and mawk (Debian
priority "required", i.e. installed by default) provides /usr/bin/awk
instead. mawk appears to not support the abbreviated func keyword. When
viewing a text/calendar part, I only see the following:

awk: /usr/libexec/aerc/filters/calendar: line 211: return outside function body

Using the standardized function keyword allows mawk to parse the prepare
function (including its return) and execute the script as intended.

[1]: https://www.gnu.org/software/gawk/manual/html_node/Definition-Syntax.html
     (section 9.2.1 "Function Definition Syntax")

Fixes: 0db924d ("filters: fix calendar filter parsing")
Changelog-fixed: Builtin `calendar` filter error with non-GNU Awk.
Signed-off-by: Timon Reinold <[email protected]>
Acked-by: Robin Jarry <[email protected]>
  • Loading branch information
Timon Reinold authored and rjarry committed Jul 16, 2024
1 parent d13823b commit a604acc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion filters/calendar
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ BEGIN {
}
}

func prepare(line) {
function prepare(line)
{
gsub($1, "", line)
gsub(/^[: ]/, "", line)
return line
Expand Down

0 comments on commit a604acc

Please sign in to comment.