Home > OS >  Ubuntu18.04 shell script to calculate the sum of two Numbers can only be effective within 256?
Ubuntu18.04 shell script to calculate the sum of two Numbers can only be effective within 256?

Time:09-26


Ballball bosses,
Why is combined and 256 its output is zero? And each cycle 256!!!!
And also,
Visit after crossing the line parameters in the second picture the number exactly is what ah?
Kowtow the pop of bam
I only had 20 points, take away all take 555

CodePudding user response:

Can someone get me a sigh

CodePudding user response:

The EXIT code for the bash/sh (EXIT STATUS), between 0-255

The EXIT STATUS
The exit status of The an executed command is The value returned by The waitpid system call or equivalent function. The exit statuses fall between 0 and

The environment for any simple command or function may be augmented temporarily by prefixing it with parameter assignments, as described above in
The PARAMETERS. These the assignment statements affect only the environment seen by that command.

If the -k option is set (see the set builtin command below), then all the parameter assignments are placed in the environment for a command, not just
Those that precede the command name.

The When bash invokes an external command, the variable _ is set to the full file name of the command and passed to that command in its environment.

CodePudding user response:

refer to the second floor mymtom response:
bash/sh EXIT code (EXIT STATUS), between 0-255

The EXIT STATUS
The exit status of The an executed command is The value returned by The waitpid system call or equivalent function. The exit statuses fall between 0 and

The environment for any simple command or function may be augmented temporarily by prefixing it with parameter assignments, as described above in
The PARAMETERS. These the assignment statements affect only the environment seen by that command.

If the -k option is set (see the set builtin command below), then all the parameter assignments are placed in the environment for a command, not just
Those that precede the command name.

The When bash invokes an external command, the variable _ is set to the full file name of the command and passed to that command in its environment.

Thank you, but this kind of means to bash/sh can't return the sum of 256 outside data?

CodePudding user response:

 
#!/bin/bash

The sum () {
Echo $(($1 + $2))
}

Echo "input the first number,"
Read n1
Echo "input the second number,"
Read n2

Res=$(the sum $$n2 n1)
Echo "$n1 + $n2=$res"
  • Related