Sponsored Content
Top Forums Shell Programming and Scripting A dash to GOTO or a dash from GOTO, that is the question... Post 303038985 by MadeInGermany on Thursday 19th of September 2019 01:30:24 AM
Old 09-19-2019
Isn't line_number always equal to or greater than start_line?
It works because the output file is truncated at the right moment.

I would rather go for
Code:
goto()
{
    line_copy=
    while IFS='' read -r line
    do
        [ "$line" = "$1" ] && line_copy=1
        [ -n "$line_copy" ] && echo "$line"
    done < "$0" > /tmp/goto.tmp
    . /tmp/goto.tmp
}

Eventually swap the two lines in the loop, to omit the first line (then you do not need to prefix the lable with a nop).

Of course this is a hack. A function puts something on the "return" stack...
This User Gave Thanks to MadeInGermany For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to goto in ksh

Hi, I'm trying to use the goto in ksh but it does not appear to be a valid command. Is that only valid in csh? Anything similar in ksh that I can use? Appreciate any help you can provide. Thanks. geraldine (4 Replies)
Discussion started by: Geraldine
4 Replies

2. Shell Programming and Scripting

Use of GOTO statement in scripts

Hey Guys.. I just want to know how to use Goto statement in shell scripts. I know the basic use of statement. Goto Label The above statement will search for some label which must be defined in the script itself as: label: I tried these combinations but I didn't work out for me and I'm... (7 Replies)
Discussion started by: vikasduhan
7 Replies

3. Shell Programming and Scripting

goto statement

I have a test script for using goto statement but its not working. please help i tried both in linux and hp-ux it's not working please help #! /bin/ksh t=`ps -ef|grep ti.sh|grep -v grep` if ; then goto start else goto stop fi start: echo "start" stop: echo "stop" (5 Replies)
Discussion started by: Krrishv
5 Replies

4. UNIX for Dummies Questions & Answers

Stuck after typing goto

uname -a returns: SMP Tue May 17 17:52:23 EDT 2005 i686 athlon i386 GNU/Linux I have many aliases beginning with "goto" so... if I type goto and then hit return (oops) A goto prompt pops up and I cant exit from it(I tried MANY key seqs) The only way to exit is to kill the term window... (2 Replies)
Discussion started by: rairey
2 Replies

5. UNIX for Dummies Questions & Answers

dash after ampersant

Hi! I'm new in these forums and more or less new with Unix. So... here is the question: does anyone know where is redirected the output of a command when you put >&- after it? Does it means any standard file descriptor? Thanks! (2 Replies)
Discussion started by: csecnarf
2 Replies

6. Solaris

Goto last visted directory

Dear All, Can any one pls let me the command for how to goback to previous visited directory from the current working directory in SunOS ? In case of HP-UX; the same can be resolved through "cd -" command. Thanks in advance! Prasanth Babu. (6 Replies)
Discussion started by: prasanth_babu
6 Replies

7. Shell Programming and Scripting

remove dash

hi I am using ksh #A="abc-def" #typeset -u B="$A" #echo $B ABC-DEF how to remove the dash? i.e. ABCDEF? thank you (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

8. Shell Programming and Scripting

Using A Goto Label?

Im trying to do something like this but I cant find any documentation. read X if then goto ThisLine fi OTHER CODE OTHER CODE Label: ThisLine echo "You entered 1" (5 Replies)
Discussion started by: Grizzly
5 Replies

9. Shell Programming and Scripting

Alternative for goto

#!/bin/sh label: echo sql poll v=`sqlplus -s <<! HR/HR set pages 0 echo off feed off select distinct status from emp where id=5; ! ` echo $v; echo it comes here after false if then echo if condition true sqlplus -l scott/tiger <<EOF select * from department; EXIT (2 Replies)
Discussion started by: kumaar1986
2 Replies

10. Ubuntu

Use of goto keyword in kernel programming

I have found many source files in the kernel using goto keyword instead of just doing the actual thing. For example: if(blah) goto x; -- -- -- -- -- x: return blah-blah Is there any specific reason for writing the code like this? The first thought that came to my mind is minimizing... (0 Replies)
Discussion started by: BHASKAR JUPUDI
0 Replies
copymsg(9F)						   Kernel Functions for Drivers 					       copymsg(9F)

NAME
copymsg - copy a message SYNOPSIS
#include <sys/stream.h> mblk_t *copymsg(mblk_t *mp); INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI). PARAMETERS
mp Pointer to the message to be copied. DESCRIPTION
copymsg() forms a new message by allocating new message blocks, and copying the contents of the message referred to by mp (using the copyb(9F) function). It returns a pointer to the new message. RETURN VALUES
If the copy is successful, copymsg() returns a pointer to the new message. Otherwise, it returns a NULL pointer. CONTEXT
copymsg() can be called from user or interrupt context. EXAMPLES
Example 1: : Using copymsg The routine lctouc() converts all the lowercase ASCII characters in the message to uppercase. If the reference count is greater than one (line 8), then the message is shared, and must be copied before changing the contents of the data buffer. If the call to the copymsg() function fails (line 9), return NULL (line 10), otherwise, free the original message (line 11). If the reference count was equal to 1, the message can be modified. For each character (line 16) in each message block (line 15), if it is a lowercase letter, convert it to an upper- case letter (line 18). A pointer to the converted message is returned (line 21). 1 mblk_t *lctouc(mp) 2 mblk_t *mp; 3 { 4 mblk_t *cmp; 5 mblk_t *tmp; 6 unsigned char *cp; 7 8 if (mp->b_datap->db_ref > 1) { 9 if ((cmp = copymsg(mp)) == NULL) 10 return (NULL); 11 freemsg(mp); 12 } else { 13 cmp = mp; 14 } 15 for (tmp = cmp; tmp; tmp = tmp->b_cont) { 16 for (cp = tmp->b_rptr; cp < tmp->b_wptr; cp++) { 17 if ((*cp <= 'z') && (*cp >= 'a')) 18 *cp -= 0x20; 19 } 20 } 21 return(cmp); 22 } SEE ALSO
allocb(9F), copyb(9F), msgb(9S) Writing Device Drivers STREAMS Programming Guide SunOS 5.10 27 Jun 1995 copymsg(9F)
All times are GMT -4. The time now is 03:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy