<s>
bs	B-Device
is	O
a	O
programming	O
language	O
and	O
a	O
compiler/interpreter	O
for	O
modest-sized	O
programs	O
on	O
UNIX	B-Application
systems	I-Application
.	O
</s>
<s>
The	O
bs	B-Device
command	O
can	O
be	O
invoked	O
either	O
for	O
interactive	O
programming	O
or	O
with	O
a	O
file	O
containing	O
a	O
program	O
,	O
optionally	O
taking	O
arguments	O
,	O
via	O
a	O
Unix	B-Application
shell	I-Application
,	O
e.g.	O
,	O
using	O
a	O
Shebang	B-Operating_System
(	O
Unix	B-Application
)	O
#	O
!	O
/usr/bin/bs	O
.	O
</s>
<s>
An	O
early	O
man	B-Protocol
page	I-Protocol
states	O
,	O
"[bs]	O
is	O
a	O
remote	O
descendant	O
of	O
Basic	O
 [ sic ] 	O
and	O
SNOBOL4	B-Application
,	O
with	O
a	O
little	O
C	B-Language
thrown	O
in.	O
"	O
</s>
<s>
The	O
bs	B-Device
command	O
appears	O
in	O
UNIX	B-Operating_System
System	I-Operating_System
III	I-Operating_System
Release	O
3.0	O
(	O
1980	O
)	O
,	O
first	O
released	O
outside	O
of	O
Bell	O
Labs	O
in	O
1982	O
.	O
</s>
<s>
It	O
was	O
written	O
by	O
Dick	O
Haight	O
(	O
Richard	O
C	B-Language
.	O
Haight	O
)	O
circa	O
1978	O
,	O
who	O
recounts	O
it	O
as	O
follows	O
:	O
</s>
<s>
The	O
Release	O
3.0	O
manual	O
mentions	O
bs	B-Device
prominently	O
on	O
page	O
9	O
(	O
emphasis	O
added	O
)	O
:	O
</s>
<s>
While	O
not	O
released	O
outside	O
prior	O
to	O
System	B-Operating_System
III	I-Operating_System
,	O
the	O
bs	B-Device
command	O
was	O
present	O
internally	O
in	O
UNIX/TS	O
1.0	O
(	O
November	O
1978	O
)	O
,	O
PWB/UNIX	B-Operating_System
2.0	O
(	O
June	O
1979	O
)	O
,	O
and	O
CB	B-Operating_System
UNIX	I-Operating_System
editions	O
2.1	O
(	O
November	O
1979	O
)	O
and	O
2.3	O
(	O
1981	O
)	O
.	O
</s>
<s>
The	O
bs	B-Device
command	O
does	O
not	O
appear	O
in	O
some	O
earlier	O
internal	O
releases	O
,	O
e.g.	O
,	O
the	O
UNIX	B-Application
Support	O
Group	O
’s	O
March	O
1977	O
release	O
,	O
nor	O
the	O
PWB/UNIX	B-Operating_System
manual	O
dated	O
May	O
,	O
1977	O
,	O
suggesting	O
its	O
creation	O
circa	O
1978	O
.	O
</s>
<s>
It	O
does	O
not	O
appear	O
in	O
any	O
version	O
of	O
Research	B-Operating_System
Unix	I-Operating_System
nor	O
the	O
Berkeley	B-Operating_System
Software	I-Operating_System
Distribution	I-Operating_System
.	O
</s>
<s>
Subsequently	O
and	O
into	O
the	O
1990s	O
,	O
bs	B-Device
was	O
included	O
in	O
a	O
variety	O
of	O
System	O
III-derived	O
or	O
System	O
V-derived	O
commercial	O
operating	O
systems	O
including	O
,	O
but	O
not	O
limited	O
to	O
:	O
PC/IX	B-Operating_System
;	O
UNIX	B-Operating_System
System	I-Operating_System
V	I-Operating_System
Releases	O
2	O
&	O
3	O
:	O
SVR2	O
,	O
SVR3	B-Operating_System
,	O
SVR3.2	O
(	O
1986	O
)	O
;	O
HP-UX	B-Application
;	O
AIX	B-Application
;	O
and	O
A/UX	B-Operating_System
.	O
</s>
<s>
(	O
The	O
User	O
's	O
Manual	O
for	O
the	O
AT&T	B-Device
UNIX	I-Device
PC	I-Device
(	O
3B1	B-Device
)	O
specifically	O
mentions	O
that	O
the	O
bs	B-Device
command	O
is	O
not	O
available	O
,	O
but	O
that	O
it	O
is	O
available	O
on	O
SVR3.2	O
.	O
)	O
</s>
<s>
Occasionally	O
,	O
bs	B-Device
was	O
touted	O
as	O
one	O
of	O
the	O
primary	O
programming	O
languages	O
for	O
development	O
under	O
UNIX	B-Application
.	O
</s>
<s>
However	O
,	O
bs	B-Device
is	O
not	O
included	O
in	O
the	O
POSIX.1	O
commands	O
and	O
utilities	O
(	O
the	O
standard	O
List	B-Application
of	I-Application
Unix	I-Application
commands	I-Application
)	O
nor	O
in	O
the	O
Single	O
UNIX	B-Application
Specification	O
and	O
is	O
not	O
provided	O
with	O
most	O
contemporary	O
operating	O
systems	O
.	O
</s>
<s>
For	O
example	O
in	O
Linux	B-Application
,	O
similar	O
syntax	O
and	O
functionality	O
is	O
provided	O
by	O
bc	B-Application
,	O
Perl	B-Language
,	O
and	O
POSIX	O
shell	O
.	O
</s>
<s>
In	O
the	O
21st	O
century	O
,	O
bs	B-Device
is	O
present	O
in	O
,	O
at	O
least	O
,	O
HP-UX	B-Application
Release	O
11i	O
(	O
2000	O
)	O
,	O
as	O
well	O
as	O
AIX	B-Application
versions	O
6.1	O
(	O
2007	O
)	O
and	O
7.2	O
(	O
2018	O
)	O
,	O
likely	O
due	O
to	O
their	O
UNIX	B-Operating_System
System	I-Operating_System
V	I-Operating_System
heritage	O
.	O
</s>
<s>
The	O
bs	B-Device
man	B-Protocol
page	I-Protocol
,	O
ostensibly	O
the	O
programming	O
language	O
's	O
only	O
specification	O
,	O
characterizes	O
it	O
as	O
follows	O
:	O
</s>
<s>
A	O
bs	B-Device
program	O
is	O
compiled	B-Language
and	O
executed	O
differently	O
from	O
programs	O
written	O
in	O
the	O
other	O
principal	O
Unix	B-Application
programming	O
languages	O
of	O
the	O
time	O
:	O
C	B-Language
,	O
FORTRAN	B-Application
,	O
and	O
assembly	B-Language
language	I-Language
,	O
whose	O
respective	O
commands	O
compile	B-Language
program	O
source	O
code	O
to	O
executable	O
assembler	B-Language
output	O
(	O
a.out	O
)	O
.	O
</s>
<s>
Instead	O
,	O
a	O
bs	B-Device
program	O
is	O
,	O
first	O
,	O
converted	O
by	O
the	O
bs	B-Device
command	O
to	O
an	O
internal	O
reverse	O
Polish	O
(	O
RPN	O
)	O
intermediate	B-Application
representation	I-Application
and	O
then	O
executed	O
by	O
the	O
command	O
's	O
internal	O
virtual	O
stack	B-Application
machine	I-Application
.	O
</s>
<s>
The	O
bs	B-Device
language	O
,	O
thus	O
,	O
is	O
a	O
hybrid	O
interpreter	B-Application
and	O
compiler	B-Language
and	O
a	O
divergence	O
in	O
Unix	B-Application
programming	O
from	O
Ancient	B-Operating_System
Unix	I-Operating_System
.	O
</s>
<s>
The	O
bs	B-Device
language	O
shares	O
some	O
features	O
and	O
syntax	O
with	O
BASIC	O
,	O
SNOBOL	B-Application
,	O
and	O
C	B-Language
,	O
the	O
two	O
former	O
presumably	O
inspiring	O
its	O
name	O
.	O
</s>
<s>
Like	O
in	O
SNOBOL4	B-Application
,	O
the	O
assignment	O
operator	O
(=	O
)	O
is	O
used	O
for	O
I/O	B-General_Concept
and	O
bs	B-Device
can	O
execute	O
code	O
in	O
strings	O
,	O
using	O
its	O
eval	O
function	O
.	O
</s>
<s>
It	O
also	O
includes	O
SNOBOL	B-Application
's	O
interrogation	O
operator	O
(	O
?	O
)	O
</s>
<s>
The	O
built-in	O
format	O
function	O
,	O
limited	O
to	O
one	O
argument	O
,	O
supports	O
a	O
subset	O
of	O
C	B-Language
's	O
printf	O
format	O
conversion	O
specifiers	O
,	O
e.g.	O
,	O
"	O
%f	O
"	O
.	O
</s>
<s>
Also	O
,	O
bs	B-Device
can	O
operate	O
in	O
two	O
modes	O
,	O
either	O
interpreting	O
(	O
and	O
executing	O
)	O
statements	O
and	O
programs	O
or	O
compiling	B-Language
them	O
,	O
and	O
switching	O
between	O
the	O
two	O
using	O
compile	B-Language
and	O
stop	O
.	O
</s>
<s>
Otherwise	O
,	O
its	O
functionality	O
is	O
unique	O
only	O
collectively	O
(	O
in	O
one	O
language	O
)	O
,	O
since	O
individual	O
features	O
are	O
redundant	O
with	O
those	O
of	O
coexisting	O
tools	O
,	O
such	O
as	O
the	O
Unix	B-Application
Shell	I-Application
,	O
e.g.	O
,	O
file	O
I/O	B-General_Concept
and	O
loops	O
,	O
and	O
AWK	B-Application
,	O
e.g.	O
,	O
associative	O
arrays	O
and	O
Regular	B-Language
expression	I-Language
matching	O
.	O
</s>
<s>
The	O
bs	B-Device
language	O
was	O
meant	O
for	O
convenient	O
development	O
and	O
debugging	O
of	O
small	O
,	O
modular	O
programs	O
.	O
</s>
<s>
It	O
has	O
a	O
collection	O
of	O
syntax	O
and	O
features	O
from	O
prior	O
,	O
popular	O
languages	O
but	O
it	O
is	O
internally	O
compiled	B-Language
,	O
unlike	O
a	O
Shell	B-Language
script	I-Language
.	O
</s>
<s>
As	O
such	O
,	O
in	O
purpose	O
,	O
design	O
,	O
and	O
function	O
,	O
bs	B-Device
is	O
a	O
largely	O
unknown	O
,	O
modest	O
predecessor	O
of	O
hybrid	O
interpreted/compiled	O
languages	O
such	O
as	O
Perl	B-Language
and	O
Python	B-Language
.	O
</s>
<s>
The	O
following	O
examples	O
are	O
derived	O
from	O
an	O
A/UX	B-Operating_System
bs(1 )	O
man	B-Protocol
page	I-Protocol
.	O
</s>
<s>
This	O
example	O
uses	O
bs	B-Device
as	O
a	O
calculator	O
:	O
</s>
<s>
This	O
example	O
is	O
the	O
outline	O
of	O
a	O
typical	O
bs	B-Device
program	O
:	O
</s>
<s>
This	O
example	O
demonstrates	O
I/O	B-General_Concept
:	O
</s>
<s>
The	O
following	O
is	O
a	O
sample	O
bs	B-Device
program	O
that	O
emits	O
the	O
words	O
to	O
the	O
song	O
99	O
Bottles	O
of	O
Beer	O
using	O
/usr/bin/bs	O
.	O
</s>
