Code Fragment Collection
Web
asperix.org
Home
Contact
Categories
BASH
Shell
PHP
APL
SQL
C++
All
Documentation
License
Related
C++ Articles
APL Library
Math Library
Geo Library
mirzoyan.com
C++ Articles
Humor
Typical warning function
This function is useful to display and record the warning count. You may later use the count as failure exit code.
function warning() { echo "$@" 1>&2 ((WARNING_COUNT++)) }
Example:
#! /bin/bash function warning() { echo "$@" 1>&2 ((WARNING_COUNT++)) } warning this is first warning warning second warning warning last warning echo "I gave you $WARNING_COUNT warnings"
Copyright (C) 2006 Andrey Mirzoyan