Sponsored Content
Full Discussion: Bash function problem
Top Forums Shell Programming and Scripting Bash function problem Post 302986199 by Chubler_XL on Monday 21st of November 2016 08:10:16 PM
Old 11-21-2016
Your code prints the output of menu scripts like this:

Code:
        0) S=M0;SC;if [[ $cur == "" ]];then R;$e "\n$(Create_Input)\n";ES;fi;;

e is defined as e='echo -en'

I'd suggest using stderr for your spin

Code:
function spin
{
  printf "\b${spinner_items:spinner_count++:1}" >&2
  ((spinner_count==${#spinner_items})) && spinner_count=0
}

This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need assistance with bash function

Hi all! I need a little help with an imbedded fuction I am trying to write. What I am trying to do is go to a series of hosts and get the contents of an XML file, storing some of the data, along with the name of the host it was gathered from. My intent is to store this in an array for later... (1 Reply)
Discussion started by: _jade_
1 Replies

2. Shell Programming and Scripting

Need help in using power function in Bash

Hi, I would like to use a power function in Bash in an awk '{ } . e.g pow(2,3)=8 Any suggestion? I try to find online resources but most of them stated by using BC. Please advise. Thanks. (3 Replies)
Discussion started by: ahjiefreak
3 Replies

3. Shell Programming and Scripting

bash search function

I want to have a function with a similar interface: search *.cpp asdf that will search recursively all directories for *.cpp file, containing line 'asdf' inside. I tried this: function search { find . -name "$1" | xargs grep -li $2; } But it doesn't work all the time. For example, if i run it... (3 Replies)
Discussion started by: doze
3 Replies

4. UNIX for Advanced & Expert Users

AWK sub function curious problem under bash

I need to detect the number of pages in a print job when it is available so I can warn users when they try to print a report much larger than they expected. Sometimes they are trying to print 1000 page reports when they thought they were getting a 10 page report. Under linux I am scanning the... (5 Replies)
Discussion started by: Max Rebo
5 Replies

5. Shell Programming and Scripting

BASH function error

Hey everyone. I am currently testing my first function based BASH script. The ultimate goal is going to be moving logs from point A to point B (or if B is down, to point C). Part of this involves the following function: function testAlive{ ping -c 1 -q $1 } Now when I run ping -c... (1 Reply)
Discussion started by: msarro
1 Replies

6. Shell Programming and Scripting

Bash function

startvm() { startguest } Is there a way use one line to get this ? actually I want startvm=startguest (5 Replies)
Discussion started by: yanglei_fage
5 Replies

7. UNIX for Dummies Questions & Answers

Bash INKEY$ function...

This is probably common knowledge to the professionals but not so much for amateurs like myself. This is a code snippet for the equivalent of BASIC's... LET char$=INKEY$ As the timeout parameter cannot be less than 1 second then this is the only limitation... It is a single line... (5 Replies)
Discussion started by: wisecracker
5 Replies

8. Shell Programming and Scripting

Yes or No selection within bash function

I need to add a selection within the bash function below and am having some trouble doing so. phox2b() { printf "\n\n" printf "What is the id of the patient getting Phox2B analysis : "; read id printf "Is this an intronic variant? Y/N "; read match_choice case... (5 Replies)
Discussion started by: cmccabe
5 Replies

9. Shell Programming and Scripting

Bash function, for BSD

I am putting this thread to shell-threads, because it is about how to make a function work properly. I need a hint for declaring a function right, it has been more than a year I did not work that straight with bash. So my aim is to turn off the eth0 (as it would be in linux, and bge0 in bsd ),... (2 Replies)
Discussion started by: 1in10
2 Replies

10. Shell Programming and Scripting

Bash script: problem with a function which use colors

Hello guys :) I've a some issue with a function which use the bash colors in my script. An example : #!/bin/bash set -x log_in(){ host="srv1" remote_files="log/" LOG_FILE="logfile" green='\033]; then color_in_red=("${red}"$2"${none}") echo -e... (2 Replies)
Discussion started by: Arnaudh78
2 Replies
SPINLOCK_DEPRECATED(3)					   BSD Library Functions Manual 				    SPINLOCK_DEPRECATED(3)

NAME
OSSpinLockTry, OSSpinLockLock, OSSpinLockUnlock -- deprecated atomic spin lock synchronization primitives SYNOPSIS
#include <libkern/OSAtomic.h> bool OSSpinLockTry(OSSpinLock *lock); void OSSpinLockLock(OSSpinLock *lock); void OSSpinLockUnlock(OSSpinLock *lock); DESCRIPTION
These are deprecated interfaces for userspace spinlocks, provided for compatibility with legacy code. These interfaces should no longer be used, particularily in situations where threads of differing priorities may contend on the same spinlock. The interfaces in <os/lock.h> should be used instead in cases where a very low-level lock primitive is required. In general however, using higher level synchronization primitives such as those provided by the pthread or dispatch subsystems are preferred. The OSSpinLock operations use memory barriers to synchronize access to shared memory protected by the lock. Preemption is possible while the lock is held. OSSpinLock is an integer type. The convention is that unlocked is zero, and locked is nonzero. Locks must be naturally aligned and cannot be in cache-inhibited memory. OSSpinLockLock() will spin if the lock is already held, but employs various strategies to back off. Because it can spin, it will generally be less cpu and power efficient than other synchronization primitives. OSSpinLockTry() immediately returns false if the lock was held, true if it took the lock. It does not spin. OSSpinLockUnlock() unconditionally unlocks the lock by zeroing it. RETURN VALUES
OSSpinLockTry() returns true if it took the lock, false if the lock was already held. SEE ALSO
atomic(3), atomic_deprecated(3) Darwin May 26, 2004 Darwin
All times are GMT -4. The time now is 01:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy