/* * gnu/tools/Printenv.java -- display system properties * Copyright (C) 1998 Wes Biggs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package gnu.tools; import java.util.Enumeration; /** * Printenv is a clone of /usr/bin/printenv, except using the * Java virtual machine's system properties. * * Usage: java gnu.tools.Printenv [--help] [--version] [property]... * * @author 0) { if (argv[0].equals("--help")) { System.out.println("Usage: java gnu.tools.Printenv [--help] [--version] [property ...]"); System.out.println("If no property is specified, print them all."); System.out.println(""); System.out.println(" --help display this help and exit"); System.out.println(" --version output version information and exit"); System.exit(0); } else if (argv[0].equals("--version")) { System.out.println("gnu.tools.Printenv 1.00, 19 November 1998"); System.exit(0); } } Enumeration ee = System.getProperties().keys(); String s; boolean b; while (ee.hasMoreElements()) { s = (String) ee.nextElement(); b = (argv.length == 0); for (i = 0; i < argv.length; i++) { if (argv[i].equals(s)) b = true; } if (b) System.out.println(s + "=" + translate(System.getProperty(s))); } } }