Debian Codegraph @

read-novar.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # read-novar.sh
3
4 echoscip-shell system . . echo.
5
6 # -------------------------- #
7 echoscip-shell system . . echo. -n "Enter a value: "
8 read var
9 echoscip-shell system . . echo. "\"var\" = "$var""
10 # Everything as expected here.
11 # -------------------------- #
12
13 echoscip-shell system . . echo.
14
15 # ------------------------------------------------------------------- #
16 echoscip-shell system . . echo. -n "Enter another value: "
17 read # No variable supplied for 'read', therefore...
18 #+ Input to 'read' assigned to default variable, $REPLY.
19 var="$REPLY"
20 echoscip-shell system . . echo. "\"var\" = "$var""
21 # This is equivalent to the first code block.
22 # ------------------------------------------------------------------- #
23
24 echoscip-shell system . . echo.
25 echoscip-shell system . . echo. "========================="
26 echoscip-shell system . . echo.
27
28
29 # This example is similar to the "reply.sh" script.
30 # However, this one shows that $REPLY is available
31 #+ even after a 'read' to a variable in the conventional way.
32
33
34 # ================================================================= #
35
36 # In some instances, you might wish to discard the first value read.
37 # In such cases, simply ignore the $REPLY variable.
38
39 { # Code block.
40 read # Line 1, to be discarded.
41 read line2 # Line 2, saved in variable.
42 } <$0
43 echoscip-shell system . . echo. "Line 2 of this script is:"
44 echoscip-shell system . . echo. "$line2" # # read-novar.sh
45 echoscip-shell system . . echo. # #!/bin/bash line discarded.
46
47 # See also the soundcard-on.sh script.
48
49 exit 0