小编Jar*_*ard的帖子

访问另一个批处理文件中的批处理函数

好吧,让我们说我们有一个名为"lib.cmd"的文件

@echo off
GOTO:EXIT

:FUNCTION
     echo something
GOTO:EOF

:EXIT
exit /b
Run Code Online (Sandbox Code Playgroud)

然后我们有一个名为"init.cmd"的文件

@echo off

call lib.cmd
Run Code Online (Sandbox Code Playgroud)

无论如何都要访问:init.cmd中的FUNCTION?就像bash使用"source"一样,将另一个bash文件运行到同一个进程中.

batch-file

11
推荐指数
1
解决办法
3673
查看次数

使用变量的值来使用该变量值

好吧,所以我试图使用变量值然后使用该变量的值来获取该变量的值.

因此,我script将其$1作为一条消息,然后将其$2作为打印出来的颜色.

#!/bin/bash

# TAKES $1 as MSG and $2 as COLOR.
export black='echo -e "\E[30;47m"'
export red='echo -e "\E[31;47m"'
export green='echo -e "\E[32;47m"'
export yellow='echo -e "\E[33;47m"'
export blue='echo -e "\E[34;47m"'
export magenta='echo -e "\E[35;47m"'
export cyan='echo -e "\E[36;47m"'
export white='echo -e "\E[37;47m"'

# VARIABLES
export color="$2"              # Set Color
export message="$1"            # Set MSG

# Use $color for what variable to substitute with, so we get the echos.
# Previously tried \$$color …
Run Code Online (Sandbox Code Playgroud)

bash

0
推荐指数
1
解决办法
77
查看次数

标签 统计

bash ×1

batch-file ×1