mardi 24 mars 2015

typeset and return status in ksh


I'd like to be able to declare a local var as the result of a command AND to be able to capture return status of command.


Something like this:



#!/bin/ksh
typeset -r command_output=$(command)
typeset -r return_status=$?
echo "$return_status" # always 0


The problem with the snippet code above is return_status will always be 0, even if command exit with another status code.


Any one to help me ?



Aucun commentaire:

Enregistrer un commentaire