URI:
       bc: Add -p to change the dc executable - sbase - suckless unix tools
  HTML git clone git://git.suckless.org/sbase
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 41883950c9421cdb8fac18f5dd3dab8f7e2463e5
   DIR parent 2544b70216bb71aec663a9657142e13ad0c6ac41
  HTML Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
       Date:   Sat, 17 Jan 2026 18:09:57 +0100
       
       bc: Add -p to change the dc executable
       
       This option is mainly added to make easier testing and enabling
       using bc with custom dc versions.
       
       Diffstat:
         M bc.1                                |       9 ++++++++-
         M bc.y                                |       9 +++++++--
         M tests/0010-bc.sh                    |       2 +-
       
       3 files changed, 16 insertions(+), 4 deletions(-)
       ---
   DIR diff --git a/bc.1 b/bc.1
       @@ -1,4 +1,4 @@
       -.Dd December 31, 2025
       +.Dd December 17, 2026
        .Dt BC 1
        .Os sbase
        .Sh NAME
       @@ -6,6 +6,7 @@
        .Nd arbitrary-precision arithmetic language
        .Sh SYNOPSIS
        .Nm
       +.Op Fl p Ar dc
        .Op Fl cdls
        .Op Ar file ...
        .Sh DESCRIPTION
       @@ -23,6 +24,12 @@ After all the files are loaded and executed then
        it reads from stdin.
        .Sh OPTIONS
        .Bl -tag -width Ds
       +.It Fl p Ar dc
       +Dc program spawned to run the translated code generated by
       +.Ar bc .
       +By default,
       +it is
       +.Ar dc .
        .It Fl c
        Compile only mode.
        Generate dc code without spawning a dc subprocess.
   DIR diff --git a/bc.y b/bc.y
       @@ -59,6 +59,8 @@ static int nested, inhome;
        static Macro macros[NESTED_MAX];
        int cflag, dflag, lflag, sflag;
        
       +static char *dcprog = "dc";
       +
        %}
        
        %union {
       @@ -803,7 +805,7 @@ spawn(void)
                        dup(fds[0]);
                        close(fds[0]);
                        close(fds[1]);
       -                execlp("dc", "dc", (char *) NULL);
       +                execlp(dcprog, "dc", (char *) NULL);
        
                        /* it shouldn't happen */
                        write(3, errmsg, sizeof(errmsg)-1);
       @@ -848,13 +850,16 @@ bc(char *fname)
        static void
        usage(void)
        {
       -        eprintf("usage: %s [-cdls]\n", argv0);
       +        eprintf("usage: %s [-p dc][-cdls]\n", argv0);
        }
        
        int
        main(int argc, char *argv[])
        {
                ARGBEGIN {
       +        case 'p':
       +                dcprog = EARGF(usage);
       +                break;
                case 'c':
                        cflag = 1;
                        break;
   DIR diff --git a/tests/0010-bc.sh b/tests/0010-bc.sh
       @@ -21,7 +21,7 @@ cat <<EOF >$tmp
        .48609126058589107690
        EOF
        
       -$EXEC ../bc ../bc.library <<EOF | diff -u $tmp -
       +$EXEC ../bc -p ../dc ../bc.library <<EOF | diff -u $tmp -
        a(0)
        a(1)
        a(2)