Weird "\n" problem
OK, here is a fun one. I have a shell-script program that was written on Slackware 2.0 or previous kernel. I have installed this same exact program on a Slackware 9.0 system. The original system that was configured acts a little differently than the new system, but I do not know if this is because of the version difference of Slackware or some user environment setting or other environment flag that has been configured on the old system.
Here is what is going on. The program has a line in it as follows:
/bin/echo "NR==1{printf\"%4.0f \",\$1}NR==2{printf \" %4.0f \",\$1}NR==3{printf \" %4.2f \",\$1}NR==4{printf \" %10.2f \",\$0*$qty}NR==5{printf \" ID%04.0f \"\$0\" ~ $qty @ %2.2f\\\n\",$inum,$amount } " >/tmp/rmenu/awkit
I know, I know, what a mess. But, the important piece is the last line, "...2.2f\\\n\",$inum,$amount..."
The output of this on the original system looks like this:
6 3 0.10 100.00 ID0006 ITEM 6 ~1 @ 100.00
The output of this on the new system looks like this:
6 3 0.10 100.00 ID0006 ITEM 6 ~1 @ 100.00\n
Note the "\n" tacked on the end. For the life of me, I cannot figure out why this is doing one thing on the original system and another on the new system. Can anyone provide any insight whatsoever into what is going on here? It is the EXACT same code running on both systems. The only differences are the version of Slackware and whatever environment settings may have been set by the guy who wrote the program (who is now dead, so I cannot ask him)
Any feedback on this is GREATLY appreciated.
|