Page 1 of 1

tip: Important tip when writing scripts

Posted: Tue Jan 16, 2007 6:14 pm
by Red Squirrel
When writing a script, or program that processes data, NEVER code in the manipulation part first. Instead make an echo/cout/printf (w/e language you're using :P) statement with the command/variables. First, work on your error checking, and format of the command.

How could this be bad? Take a classmate's script example, it went something like this:

Code: Select all

#!/bin/bash

#todo: error checking

mv $1/* .
[code]


Guess what happens if you just execute the script with no parameters?


Within the end of the period, I managed to restore his system and get it booting up again. 

[color=#888888][size=85]Archived topic from Iceteks,  old topic ID:4676, old post ID:37185[/size][/color]