Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Eval
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== bs === [[bs (programming language)|bs]] has an <code>eval</code> function that takes one string argument. The function is both an expression evaluator and a statement executor. In the latter role, it can also be used for error handling. The following examples and text are from the <code>bs</code> [[man page]] as appears in the [[UNIX System V]] Release 3.2 Programmer's Manual.<ref name=SVR32>{{cite book |title = UNIX Programmer's Manual |section = Volume 1 Commands and Utilities |year = 1986 |publisher = AT&T |page = 41 |url=https://bitsavers.trailing-edge.com/pdf/att/unix/System_V_Release_2/UNIX_Programmers_Manual_Vol_1_Commands_and_Utilities_1986.pdf}} </ref> {{Quote |text=The string argument is evaluated as a <code>bs</code> expression. The function is handy for converting numeric strings to numeric internal form. The <code>eval</code> can also be used as a crude form of indirection, as in the following (Note that, in <code>bs</code>, <code>_</code> (underscore) is the concatenation operator.): <syntaxhighlight lang="bash"> name = "xyz" eval("++" _ name) </syntaxhighlight> which increments the variable <code>xyz</code>. In addition, <code>eval</code> preceded by the interrogation operator, <code>?</code>, permits the user to control <code>bs</code> error conditions. For example: <syntaxhighlight lang="bash"> ?eval("open(\"X\", \"XXX\", \"r\")") </syntaxhighlight> returns the value zero if there is no file named "XXX" (instead of halting the user's program). The following executes a <code>goto</code> to the label <code>L</code> (if it exists): <syntaxhighlight lang="bash"> label = "L" if !(?eval("goto " _ label)) puterr = "no label" </syntaxhighlight> }}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)