Shell to determine whether the script has syntax errors

Source: Internet
Author: User

Determines whether a specified script is a syntax error, and if there is an error, prompts the user to type Q or Q to ignore the error and exit, and any other key can open the specified script via vim;


#! /bin/bash

Script_file= "./test.sh"

Sh-n $script _file>/dev/null 2 >/dev/null

N= ' echo $? '

If [$n-ne 0];then

Read-p "This script was a bad file," q "or" Q "---exit, and other key to edit the file:" Key

if [$key = = ' Q '-o $key = = ' Q ']

Then

Exit

Else

VI $script _file

Fi

Fi





This article is from the "Practical Linux knowledge and Skills sharing" blog, please be sure to keep this source http://superleedo.blog.51cto.com/12164670/1892192

Shell to determine whether the script has syntax errors

Related Article

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.