From owner-freebsd-questions Tue Apr 1 13:36:29 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id NAA02743 for questions-outgoing; Tue, 1 Apr 1997 13:36:29 -0800 (PST) Received: from matrix.42.org (sec@matrix.42.org [192.68.213.129]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id NAA02736 for ; Tue, 1 Apr 1997 13:36:23 -0800 (PST) Received: (from sec@localhost) by matrix.42.org (8.6.12/8.6.12) id XAA05850; Tue, 1 Apr 1997 23:36:19 +0200 To: freebsd-questions@freebsd.org Path: sec From: sec@42.org (Stefan `Sec` Zehl) Newsgroups: muc.lists.freebsd.questions Subject: Re: 'GET A LIFE' doesn't work Date: 1 Apr 1997 23:36:18 +0200 Organization: Internet@home Lines: 67 Message-ID: References: <199704010048.QAA29694@gabber.c2.net> X-Newsreader: slrn (0.9.3.0-2 BETA UNIX) Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In article <199704010048.QAA29694@gabber.c2.net>, sameer wrote: > Why doesn't: > > echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc > > work as expected on freebsd? I traced it down a little (heavily relying on the Manpage :) it does nothing more that continually dividing the number (3135071790101768542287578439) by 256 and printing the reminders... # store letter 'q' in register a [q]sa # store command "ln0=aln256%Pln256/snlbx" in register b [ln0=aln256%Pln256/snlbx]sb # store number "3135071790101768542287578439" in register n 3135071790101768542287578439sn # load register b on stack and execute as command lbx # quit q While the command in "b" does: # load reg. a on stack, compare it with 0, if true execute reg. a (= quit) ln 0 =a # load reg. a on stack, do modulo 256 and Print this value ln 256 % P # load reg. a on stack, divide (integer) by 256 an store it in reg. n again ln 256 / sn # load reg. b on stack and execute as command (recursion) lbx So, so far for the difficult part, now why doesn't this work on FreeBSD ? it's the 'P' command of FreeBSD's dc on FreeBSD: echo '71Pq'|dc yields "71" on SunOS: echo '71Pq'|dc yields "G" from the SunOS manpage: P Interpret the top of the stack as an ASCII string, remove and print it. from the FreeBSD manpage: P Prints the value on the top of the stack, popping it off, and does not print a newline after. so they don't even claim to do the same.... The magic question is now, should this behavior be changed ? CU, Sec -- Fuer die Raupe ist es das Ende der Welt, Fuer den Rest der Welt ist es ein Schmetterling Error 0: No error