PLEASE NOTE: this server,, will be unavailable on WEDNESDAY 7th December, from 1pm until 4pm.
Web-based programs, such as csmarks, cssubmit, and the help fora, will all be unavailable.
  It's UWAweek 49


This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying the 2 articles in this topic
Showing 2 of 564 articles.
Currently 3 other people reading this forum.

 UWA week 22 (1st semester, study break) ↓
SVG not supported

Login to reply

10:06pm Sun 5th Jun, Chuanhe L.

hi Michael, this is Chuanhe. here is a simple question about shell function i write a script like below 1 #!/bin/sh 2 3 m(){ 4 return $1 5 } 6 echo $(m $1) i try ./script 5, but echo nothing here, wonder why

 UWA week 23 (1st semester, 1st exam week) ↓
SVG not supported

Login to reply

2:42am Mon 6th Jun, ANONYMOUS

Chuanhe, Shell functions can only return an exit status (a number). It cannot return string. We can capture the exit status with $? Here is a code with a simple function. #/bin/bash function test { echo $1 return 123 } test 'Hello' echo $?

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  1:17AM Sep 14 2022
Privacy policy