GCC 4.3 configure script Learning (2): Be Bourne compatible

Source: Internet
Author: User

In configure, the first section is: If test-n "$ {zsh_version + set}" & (emulate SH)>/dev/null 2> & 1; then emulate sh nullcmd =: # zsh 3.x and 4.x performs word splitting on ${1 + "$ @"}, which # is contrary to our usage. disable this feature. alias-G' ${1 + "$ @"} '=' "$ @" 'elif test-n "$ {bash_version + set}" & (set-O POSIX )> /dev/null 2> & 1; then set-O posixfidualcase = 1; export dualcase # For mks sh learning! 1If If statement test condition. After the test condition returns true (0) or false (1), you can execute a series of statements accordingly. The I f statement structure is very useful for error checks. The format is: If Condition 1 Then Command 1 Elif Condition 2 Then Command 2 Else Command 3 Fi Very simple. When using the I f statement, the part t h e n must be placed in the new line; otherwise, an error occurs. If you want to remove a branch, you must use the command separator. 2Test When writing a script, you may need to check whether the string is equal or not. You may also need to check the file status or perform a digital test. Further actions can be performed based on these tests. The Te s t command is used to test strings, file statuses, and numbers. T e S t generally has two formats: Test Condition Or [C o n d I t I o n] When square brackets are used, add spaces on both sides of the condition. String testing is an important part of error capture, especially when testing user input or compare variables. There are five formats for string testing. L Test "string" L Test string_op "string" L Test "string" string_op "string" L [String_op string] L ["String" string_op "string"] Here, s t r I n g _ o p can be: = two strings are equal .! = Two strings. -Z empty string. -N is a non-empty string. 3Variable assignment In the preceding statement: $ {Zsh_version + set} Is the value assignment operation on the variable. zsh_version and bash_version are different shell defined values and are read-only. For cygwin, The bash_version value is 3.2.33 (18)-release. The plus sign indicates that if v a r I a B l e-n a m e is set, the value is reset. The returned result is the final value of the variable. Other related values are: va r I a B l e-n a m e = v a l u e set the actual value to v a r I a B l e-n a m Eva R I A B L e-n a m e + v a l u e if v a r I a B l e-n a m e is set, then reset its value, va r I a B l e-n a m E :? V a l u e if v a r I a B l e-n a m e is not set, the undefined user error message is displayed. Va r I a B l e-n a m e? V a l u e if v a r I a B l e-n a m e is not set, the system error message va r I a B l e-n a m e is displayed: = v a l u e if v a r I a B l e-n a m e is not set, set its value va r I a B l e-n a m E: -v a l u e is the same as above, but the value is not set to v a r I a B l e-n a m e. It can be replaced. Code , The first condition of the IF statement will be false, and The Emulate sh will not be executed. The first condition of Elif is true. 4Set Set is a built-in bash command. The interpretation of Set-o posix in man page is: change the behavior of bash where the default operation differs from the POSIX standard to match the mode standard (POSIX mode ). if the command succeeds, the return value is 0. 5Redirection Common redirection commands in Linux: Command> filename redirects the standard output to a new file. Command> filename redirects the standard output to a file (append) command 1> fielname redirects the standard output to a file. Command> filename 2> & 1 redirects the standard output and standard error to a file. Command 2> filename redirects the standard error command 2> filename in a file redirects the standard output to a file (append) command> filename 2> & 1 redirects the standard output and standard error to a file (append) command <FILENAME> filename2 uses the c o m a n d command to use the f I l e n a m e file as the standard input, output comman using the f I l e n a m E 2 file as the standard D <FILENAME uses the c o m a n d command to use the f I l e n a m e file as the standard input command <delimiter reads from the standard input, until the division command of d e l I m I t e r is met <& M uses the file descriptor m as the standard input command> & M redirects the standard output to the file descriptor M command <& -Close the standard input, so>/dev/null 2> & 1 is easy to understand, that is, the output of error messages and commands is not displayed. 6Export Environment variables are used for all user processes (often referred to as subprocesses ). A logon process is called a parent process. User processes executed in s h e l are called sub-processes. Unlike local variables (only for current s h e l), environment variables can be used for all sub-processes, including editors, scripts, and applications. Traditionally, all environment variables are capitalized. Before applying environment variables to user processes, you must use the e x P o r t command to export them. Environment variables are set in the same way as local variables. Dualcase = 1; export dualcase # For mks SH is an environment variable called dualcase.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.