Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Aug 1999 08:20:55 -0400 (EDT)
From:      James Howard <howardjp@wam.umd.edu>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/13070: line(1) as required by Unix 98
Message-ID:  <199908111220.IAA04659@rac10.wam.umd.edu>

next in thread | raw e-mail | index | archive | help

>Number:         13070
>Category:       bin
>Synopsis:       line(1) as required by Unix 98
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 11 05:30:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     James Howard
>Release:        FreeBSD 3.2-STABLE i386
>Organization:
University of Maryland
>Environment:

FreeBSD byzantine 3.2-STABLE FreeBSD 3.2-STABLE #5: Sat Aug  7 23:43:54 GMT 1999     root@byzantine:/usr/src/sys/compile/BYZANTINE  i386

>Description:

After opening my big mouth on freebsd-advocacy about how Unix 98
compliance was a worthy goal, more than one person told me to go
ahead and send in PRs with changes.  Well, here is one :)

This contains a shar of line(1).  It reads in one line of text 
up to and including a new line and prints it to the standard output.  
It has been depreciated in Unix 98 and will probably be removed in 
the next edition of the standard.

>How-To-Repeat:

Irrelevant.

>Fix:
	
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	Makefile
#	line.1
#	line.c
#
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
XPROG=line
X
X.include <bsd.prog.mk>END-of-Makefile
echo x - line.1
sed 's/^X//' >line.1 << 'END-of-line.1'
X.\" Copyright (c) 1999 James Howard
X.\" All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\"
X.\"     $Id$
X.\"
X.Dd August 9, 1999
X.Dt LINE 1
X.Os
X.Sh NAME
X.Nm line
X.Nd read and output one line
X.Sh SYNOPSIS
X.Nm
X.Sh DESCRIPTION
XThe 
X.Nm
Xutility reads one line text up to and including a 
Xnew line from the standard input and prints that line
Xto the standard output.  It always prints at least
Xa new line.
X.Pp
XThis utility has been depreciated and users should
Xmigrate to the 
X.Xr read 1
Xutility.
X.Sh DIAGNOSTICS
XThe 
X.Nm
Xutility returns 1 if an end of file condition is 
Xreached on the standard input; 0 is returned otherwise.
X.Sh SEE ALSO
X.Xr csh 1 ,
X.Xr sh 1
X.Sh STANDARDS
XThe
X.Nm
Xutility is expected to be XPG5 compliant.
END-of-line.1
echo x - line.c
sed 's/^X//' >line.c << 'END-of-line.c'
X/*-
X * Copyright (c) 1999 James Howard
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X *
X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X *
X *      $Id$
X */
X
X#include <stdio.h>
X
X/*
X * An XPG5 compliant implementation of line(1).  The line utility reads a
X * line of text from the standard input and prints it to the standard output.
X */
X
Xint
Xmain(void)
X{
X	char *l;
X	int   len;
X
X	/* Grab a line and print it. */
X	l = fgetln(stdin, &len);
X	(void) fwrite(l, len, 1, stdout);
X
X	/*
X	 * Check for the special condition that EOF was encountered on the
X	 * standard input and that a newline was not the last character in
X	 * the buffer.  If it is not, print one.
X	 */
X	if (l[len - 1] != '\n')
X		fputc('\n', stdout);
X
X	/*
X	 * Find out if we received EOF on the standard input and return that
X	 * as the exit status.
X	 */
X	return feof(stdin);
X}
END-of-line.c
exit




>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908111220.IAA04659>