Not logged in
Log in now
Create an account
Subscribe to LWN
Pencil, Pencil, and Pencil
Dividing the Linux desktop
LWN.net Weekly Edition for June 13, 2013
A report from pgCon 2013
Little things that matter in language design
$ cat /home/mg/bin/proxy-on
gconftool -s /system/proxy/mode -t string manual
$ cat /home/mg/bin/proxy-off
gconftool -s /system/proxy/mode -t string none
Mark Shuttleworth at LinuxTag
Posted Jun 17, 2010 10:57 UTC (Thu) by zzxtty (subscriber, #45175)
Posted Jun 17, 2010 13:42 UTC (Thu) by marcH (subscriber, #57642)
Posted Jun 18, 2010 13:33 UTC (Fri) by zzxtty (subscriber, #45175)
These should do the trick (untested):
alias proxy-on='gconftool -s /system/proxy/mode -t string manual'
alias proxy-off='gconftool -s /system/proxy/mode -t string none'
A 'script'* would have to spawn a new shell to process the command, rather inefficient.
*I can't quite bring myself to call a one liner a script!
Posted Jun 19, 2010 16:31 UTC (Sat) by bronson (subscriber, #4806)
True. In those situations where you want to switch your proxy 300 times per second, this is very important! ;)
Trading some performance for modularity and maintainability is usually a pretty good idea.
Posted Jun 21, 2010 6:50 UTC (Mon) by zzxtty (subscriber, #45175)
Well you never know... No, from a performance point of view you are quite right. However I have been in the situation where I've been on machines which are constantly running out of process ids and every little helps (eg: echo *). Admittedly I don't see switching your proxy on and off would be a particularly high priority in such a situation!
"Trading some performance for modularity and maintainability is usually a pretty good idea."
You've lost me slightly there, I would have thought having one .cshrc (or .bashrc?) would be more maintainable than a bin directory full of separate files. I guess we all have our preferred ways of working!
Posted Jun 25, 2010 10:54 UTC (Fri) by robbe (guest, #16131)
My maintainability concern with putting aliases in .bashrc is that only a single shell sees that.
Coming back to performance, the alias solution does incur the (small) per-shell cost of reading, parsing, and keeping in memory the alias, when in most shells you will never need it.
IIRC zsh has one-per-file functions that can reside in a directory somewhere. This is probably the optimal solution here: as maintainable as a shell script, loaded on demand, does not fork a new shell.
Posted Jun 28, 2010 20:01 UTC (Mon) by bjartur (subscriber, #67801)
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds