Re: Why /bin/sh doesn't like the line: if test x$my_var == xyes; then
On Thu, Sep 03, 2009 at 06:59:38AM +0200, Polytropon typed: What is the version of /bin/sh currently used in 7.2? Where is it taken from? --version, -v, -version don't ever print version I guess due to FreeBSD policy of not versioning individual utilities. FreeBSD's Bourne shell does not have GNU long options such as --version. According to the shell's manpage, -v is used for verbosity, and -version isn't even defined. Refer to man sh for more options. The parts of the base system (as in opposite to Linux where no real the OS does exist) usually have the version of the release, but to be more precise, the individual version can be obtained from the source code. It can be found in /usr/src/bin/sh. For example, I have @(#)main.c 8.6 (Berkeley) 5/28/95 $FreeBSD: src/bin/sh/main.c,v 1.29 2006/10/07 16:51:16 stefanf Exp $ in the source file main.c, and the Makefile indicates @(#)Makefile8.4 (Berkeley) 5/5/95 $FreeBSD: src/bin/sh/Makefile,v 1.46 2006/04/17 17:55:11 schweikh Exp $ as its particular version number and date. Also, versions of all individual source files are usually displayed by ident(1): nih# ident /bin/sh /bin/sh: $FreeBSD: src/lib/csu/i386-elf/crti.S,v 1.7.20.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/lib/csu/i386-elf/crtn.S,v 1.6.20.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/lib/csu/common/crtbrand.c,v 1.4.20.1.6.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/lib/csu/i386-elf/crt1.c,v 1.15.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/alias.c,v 1.20.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/arith.y,v 1.21.2.1.4.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/arith_lex.l,v 1.24.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/cd.c,v 1.35.2.1.4.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/bltin/echo.c,v 1.14.28.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/error.c,v 1.26.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/eval.c,v 1.54.2.1.4.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/exec.c,v 1.31.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/expand.c,v 1.51.2.2.4.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/histedit.c,v 1.29.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/input.c,v 1.23.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/jobs.c,v 1.72.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/mail.c,v 1.14.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/main.c,v 1.29.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/memalloc.c,v 1.27.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/miscbltin.c,v 1.35.2.1.2.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/mystring.c,v 1.13.28.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/options.c,v 1.25.2.2.4.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/output.c,v 1.20.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/parser.c,v 1.58.2.1.4.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/redir.c,v 1.26.28.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/show.c,v 1.23.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/test/test.c,v 1.53.20.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/trap.c,v 1.32.8.1 2009/04/15 03:14:26 kensmith Exp $ $FreeBSD: src/bin/sh/var.c,v 1.37.8.1 2009/04/15 03:14:26 kensmith Exp $ Ruben ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Why /bin/sh doesn't like the line: if test x$my_var == xyes; then
Hi, Am Donnerstag, 03. Sep 2009, 04:14:56 + schrieb jerry M: configure file got this line and it causes the message: test: xyes: unexpected operator But removing spaces around == or replacing == with = makes it to work. On Linux though this line works fine. As `man test' describes, the /bin/test executable does not recognize a == operator. Neither in `sh' nor in `bash' the `test' executable will be called (unless written as /bin/test). In both cases it is a builtin command. The Sh builtin works like the `test' executable; the Bash builtin recognizes ==. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Why /bin/sh doesn't like the line: if test x$my_var == xyes; then
configure file got this line and it causes the message: test: xyes: unexpected operator But removing spaces around == or replacing == with = makes it to work. On Linux though this line works fine. Why spaces around == would cause failure? What is the version of /bin/sh currently used in 7.2? Where is it taken from? --version, -v, -version don't ever print version I guess due to FreeBSD policy of not versioning individual utilities. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Why /bin/sh doesn't like the line: if test x$my_var == xyes; then
On Thu, 3 Sep 2009 04:14:56 + (GMT), jerry M jerrry94...@yahoo.com wrote: configure file got this line and it causes the message: test: xyes: unexpected operator But removing spaces around == or replacing == with = makes it to work. Maybe those files are not intended to run on FreeBSD's standard Bourne shell? On Linux though this line works fine. This may be due to the fact that on most Linusi, sh is bash. On FreeBSD, sh is a different shell than bash; it's the original Bourne shell. Why spaces around == would cause failure? First of al, refer to man test for the string operators. The form == isn't mentioned there. s1 = s2 True if the strings s1 and s2 are identical. s1 != s2 True if the strings s1 and s2 are not identical. s1 s2 True if string s1 comes before s2 based on the binary value of their characters. s1 s2 True if string s1 comes after s2 based on the binary value of their characters. Furthermore, it's wise to enclose the variable names in curly brackets when used in a compositum. Your statement if test x$my_var == xyes; then would correctly read as follows: if test x${my_var} = xyes; then You can of course use [ instead of test, so it would be if [ x${my_var} = xyes ]; then What is the version of /bin/sh currently used in 7.2? Where is it taken from? --version, -v, -version don't ever print version I guess due to FreeBSD policy of not versioning individual utilities. FreeBSD's Bourne shell does not have GNU long options such as --version. According to the shell's manpage, -v is used for verbosity, and -version isn't even defined. Refer to man sh for more options. The parts of the base system (as in opposite to Linux where no real the OS does exist) usually have the version of the release, but to be more precise, the individual version can be obtained from the source code. It can be found in /usr/src/bin/sh. For example, I have @(#)main.c 8.6 (Berkeley) 5/28/95 $FreeBSD: src/bin/sh/main.c,v 1.29 2006/10/07 16:51:16 stefanf Exp $ in the source file main.c, and the Makefile indicates @(#)Makefile8.4 (Berkeley) 5/5/95 $FreeBSD: src/bin/sh/Makefile,v 1.46 2006/04/17 17:55:11 schweikh Exp $ as its particular version number and date. The manual man sh includes this statement: The sh utility is the standard command interpreter for the system. The current version of sh is in the process of being changed to conform with the IEEE Std 1003.2 (``POSIX.2'') specification for the shell. This ver- sion has many features which make it appear similar in some respects to the Korn shell, but it is not a Korn shell clone like pdksh. Only fea- tures designated by POSIX, plus a few Berkeley extensions, are being incorporated into this shell. This man page is not intended to be a tutorial nor a complete specification of the shell. as well as This version of sh was rewritten in 1989 under the BSD license after the Bourne shell from ATT System V Release 4 UNIX. It's important, especially for interoperability, to declare #/bin/sh only and ONLY if the script is for Bourne shell. If you're using bash specifics, use #!/usr/local/bin/bash instead. Keep in mind that you'll have to install bash (pkg_add -r bash) in this case. A tidy way of coding, such as using the curly brackets, is an important thing, too, as you can see. :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Why /bin/sh doesn't like the line: if test x$my_var == xyes; then
In the last episode (Sep 03), jerry M said: configure file got this line and it causes the message: test: xyes: unexpected operator But removing spaces around == or replacing == with = makes it to work. On Linux though this line works fine. Why spaces around == would cause failure? What is the version of /bin/sh currently used in 7.2? Where is it taken from? --version, -v, -version don't ever print version I guess due to FreeBSD policy of not versioning individual utilities. == isn't a valid comparison operator for the test command. See the FreeBSD manpage, or the Posix docs: http://www.opengroup.org/onlinepubs/9699919799/toc.htm. You need to use =. Certain Linux distributions use bash as /bin/sh, which shortcuts the test command internally and allows bash extensions, even in bourne-shell mode. Debian and Ubuntu use dash instead of bash, and this script would fail on them as well. -- Dan Nelson dnel...@allantgroup.com ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org