Shell script debugging tool set

Source: Internet
Author: User

You can use the x option of the set command to display all command execution and variable value change processes.

Usage: First UseSet-x to enable debugging, And finally use the commandSet + x disable debugging mode.

A simple example shows how to use the set command for script debugging:

! /Bin ///-

++ X

[Root @ localhost shell] #./+ NAME = ++ x

In the preceding results, you must note that all rows starting with the plus sign "+" are executed commands, and all rows without the plus sign "+" at the beginning are Script output, all variables in the script are replaced by values.

If there is a logic error in the script, you can clearly see the script execution process and error location during the above debugging process.

When you use the x option of the set command to start the debugging mode, you do not have to debug all statements, you can also use set-x and set + x to debug one or more problematic scripts.

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.