The Bourne, Bash, and Korn shells display a blank line, unless you request error checking with the set –u or the shell's –u invocation option. The C and TC shells will tell you when you are using an undefined variable. When switching from one shell to another, it is easy to forget when to use set and when to use or not use spaces. Space is not allowed on either side of the = sign. ![]() The set command in bash, sh, and ksh is used to set shell options or create positional parameters, but is not used to define variables. When setting a variable in the C/TC shells, the set command is used, and the = sign must be surrounded with space (or no space at all). ![]() ![]() And because UNIX/Linux is case sensitive, even changing from uppercase to lowercase can cause a program to fail. Although this may seem more convenient than having to declare every variable explicitly, there is an unfortunate consequence: An inadvertent spelling error might introduce an extra variable that you had no intention of creating. ![]() When a variable name is used in a program, the variable is created automatically. Probable Causes for Syntax Errors 15.4.1 Undefined and Misspelled VariablesĪs you know, the shells do not require variables to be declared.
0 Comments
Leave a Reply. |