The Test in the LINUX Shell
来源:互联网 发布:夜鹰淘宝 编辑:程序博客网 时间:2024/04/29 11:05
Tests occur on a daily basis in our life, from seeing if you can get up early enough to get to your job to seeing how good you are at passing tests. When you start to do shell programming, tests will be just as important. You want to test files, expressions, variables, strings and more for certain traits. To make this easier, a command was introduced, which we will learn how to use today.
There are multiple kinds of structures which we can check for some attribute. While we work in the shell, we may have a file, strings, and/or logical expressions composed of commands or numbers. To learn a different function, a method to check its traits for all of this can be time consuming. To reduce the work involved, a command has been introduced a command that covers this. Intuitively enough, the name of the command is: test.
Of course, there are different expressions and options depending on what you want to check. However, these are quite intuitive and make the work much easier. There are two types of accepted syntaxes for the command.
The general one:
test expression
Alternatively, you may call it also like this:[ expression ]
The second version is easier to read, and because of this we use it more often. Nevertheless, if you decide to take advantage of this option you have to make sure that you leave a space before and after the [ and ] characters.#!/bin/sh# REPLACE with your PHP5 binary path (example: /usr/local/php5/bin/php )#MAGE_PHP_BIN="php"MAGE_PHP_SCRIPT="mage.php"DOWNLOADER_PATH='downloader'# initial setupif test "x$1" = "xmage-setup"; then echo 'Running initial setup...' if test "x$2" != "x"; then MAGE_ROOT_DIR="$2" else MAGE_ROOT_DIR="`pwd`" fi $0 config-set magento_root "$MAGE_ROOT_DIR" $0 config-set preferred_state beta $0 channel-add http://connect20.magentocommerce.com/community exitfi# check that mage pear was initializedif test "x$1" != "xconfig-set" && test "x$1" != "xconfig-get" && test "x$1" != "xconfig-show" && test "x$1" != "xchannel-add" && test "x`$0 config-get magento_root`" = "x"; then echo 'Please initialize Magento Connect installer by running:' echo "$0 mage-setup" exit;fi# find which PHP binary to useif test "x$MAGE_PHP_BIN" != "x"; then PHP="$MAGE_PHP_BIN"else PHP=phpfi# get default pear dir of not setif test "x$MAGE_ROOT_DIR" = "x"; then MAGE_ROOT_DIR="`pwd`/$DOWNLOADER_PATH"fiexec $PHP -C -q $INCARG -d output_buffering=1 -d variables_order=EGPCS \ -d open_basedir="" -d safe_mode=0 -d register_argc_argv="On" \ -d auto_prepend_file="" -d auto_append_file="" \ $MAGE_ROOT_DIR/$MAGE_PHP_SCRIPT "$@"
- The Test in the LINUX Shell
- Cocoa in the Shell
- The blank in SHELL
- HowTo: Run the .sh File Shell Script In Linux / UNIX
- How to Enable the Linux Bash Shell in Windows 10
- Communication skill in the software test
- The symble '-' in Linux
- Test the efficiency of the exclusion objects in Windows
- Reporting the Test Results in Microsoft Test Manager
- add the disk in the linux
- Somethings about the Process in the Linux
- "Dogs" of the linux shell
- 解读《GHOST IN THE SHELL》的世界
- Ghost in the Shell 2: Innocence
- shell iterate the directory in recursive way
- The useful commands in linux
- analysis the usb in linux
- Config The Eclipse In Linux
- HTML DOCTYPE 标签 -- DTDs 文档类型声明
- android获取正在运行的应用程序
- 亲,我给你们的开幕式“好评”
- Log to file in Qt.
- Android setOnClickListener使用方法
- The Test in the LINUX Shell
- JQuery对checkbox操作 (循环获取)
- Ubuntu 12.04 root默认密码? 如何使用root登录?
- 2012年阅读总结
- Jquery 验证框架用法
- java基础学习笔记(三)
- interrupt 和 using 在C51中断中的使用
- groovy 三种运用
- 网站打开速度慢的原因分析及对策