Sunday 7 July 2019

bash - The function definitions in shell use dash

The following code:



#!/bin/bash


function me-test()
{
echo 'test'
}

me-test


The execution method below is not correct:




#sh 1.sh
1.sh: line 6: `me-test': not a valid identifier


but the execution method below is correct:



#./1.sh
test



In other programming languages,it can not using dash to define function.For example,python.



why shell is so that?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...