GNU DC on Debian11:
$ dc --version
dc (GNU bc 1.07.1) 1.4.1
Copyright 1994, 1997, 1998, 2000, 2001, 2003-2006, 2008, 2010, 2012-2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
$ dc -e '1 r'
$ echo $?
0
GH-DC on Debian11:
$ dc --version
dc 6.6.0
Copyright (c) 2018-2023 Gavin D. Howard and contributors
Report bugs at: https://git.gavinhoward.com/gavin/bc
This is free software with ABSOLUTELY NO WARRANTY.
$ dc -e '1 r'
Runtime error: stack has too few elements
0: (main)
$ echo $?
3
That's FreeBSD's default DC. NetBSD's and OpenBSD's DC yield similar results with a slightly different error text.
I think GNU DC should error too as there is nothing to swap if r
is given only a one element deep stack. Or is there a good reason to tolerate this?