Flux rss

Modifying a read-only variable

Published by netty5, last update on Tuesday November 18, 2008 08:27:33 AM by netty5

Modifying a read-only variable




Solution 1


A variable declared as read-only can not be modified during outgoing process.
But if the variable is exported in a child shell it may be modified.

#!/bin/bash

if [ "$PROC_PID" != "$PPID" ]; then
  export PROC_PID=$$
  var="mype"
  echo "initial $var"

  declare -r var

  export var
  $0 & # child process 
else
  echo "before $var"
  var="netty5"
  echo "after $var"
fi

Solution 2


Making use of indirect development.

# Declaration of read-only Variable
$ readonly Z="Y"
$ echo $Z
Y

# Suppression test 
$ unset Z
-l: unset: Z: cannot unset: readonly variable

# Replacement test
$ Z=W
-l: Z: readonly variable

# Declaration of an indirect variable
$ Y=W
$ echo "$Y"
W

# Development of variable with indirection
$ echo "${!Z}"
W

$
Download SongBird Songbird is a multimedia reader coupled with the web (mash-up). Having based on the motor Mozilla, him allows to search audio contents across broad one range of Websites offering this type of contents and to read them via readers' variety MP3 (ipod,... en.kioskea.net/telecharger/telecharger-358-songbird
How to read a RealMedia Variable (RMVB) Bitrate file How to read a RealMedia Variable (RMVB) Bitrate file What is a RMVB file? How to read a RealMedia Variable Bitrate file Convert a RealMedia File Using EO Video What is a RMVB file? RMVB is the acronym used for RealMedia Variable... en.kioskea.net/faq/sujet-232-how-to-read-a-realmedia-variable-rmvb-bitrate-file
What is an MKV file and how to read it What is an MKV file and how to read it What is an MKV file? An MKV file is an audio and video container that can support various audio, video and subtitle compression formats. MKV files usually have a menu system slightly similar to a DVD menu,... en.kioskea.net/faq/sujet-286-what-is-an-mkv-file-and-how-to-read-it
How to read a .DOCX documentHow to read a .DOCX document Download Microsoft Compatibility Pack Download XML Translator Making use of online Tools For MAC users The new Office 2007 includes a new format for the word documents that bears the .docx extension.... en.kioskea.net/faq/sujet-317-how-to-read-a-docx-document
How to read and create a BIN and CUE file?How to read and create a BIN and CUE file? What is a BIN file? How to create BIN and CUE files How to burn BIN and CUE files How to read/convert BIN and CUE files What is a BIN file? A BIN and CUE file together create a binary... en.kioskea.net/faq/sujet-264-how-to-read-and-create-a-bin-and-cue-file
How to read and create a .NRG fileHow to read and create a .NRG file What is a .NRG file? A file with the .NRG extension is a CD image file generated by softwares like Nero Burning ROM. Other programs like Alcohol 120% and Daemon Tools can create NRG files onto virtual... en.kioskea.net/faq/sujet-238-how-to-read-and-create-a-nrg-file
Cannot 'Read' CD on D Drive, Windows Vista, (Solved)Hello, I have been unable to 'Read' any CD's in the 'D' Drive on my laptop, Toshiba, using Windows Vista as an Operation System. I have a friend who has the exact same problem. What do we need to be able to listen to this CD... en.kioskea.net/forum/affich-28814-cannot-read-cd-on-d-drive-windows-vista
DVD/RW will not read anythingHello, my DVD/RW will not read cds, dvds or data discs. I used it regularly for burning both cds and dvds, up until 2days ago when it suddenly decided to stop working for reasons unknown. I have been to device manager which says there is no problems,... en.kioskea.net/forum/affich-12954-dvd-rw-will-not-read-anything
DVD ROM not reading CDsHey dudes, what’s the problem with my dvd rom? It is reading dvds but not cds what shall I do with it? It’s a LG. any idea please ? en.kioskea.net/forum/affich-17795-dvd-rom-not-reading-cds
Download Open Cubic PlayerOpen Cubic Player is a reader of big musics on platforms 9x / Miss of Windows and BACK. He can read a variety of formats of sound on soudn cards.Nowadays, it supports formats 669, AMS, BPA, CDA, DMF, SHONE, MDL, at the MI, MOD, MP3, MTM, MXM, OKT,... en.kioskea.net/telecharger/telecharger-325-open-cubic-player
Download Alarm Clock Pro for WindowsAlarm Clock Pro lets you manage your daily timing and automatically perform various tasks such as: read your list of Favorite song iTunes. It will display quotes randomly throughout the day and send them as text message to your cell phone. It also... en.kioskea.net/telecharger/telecharger-1390-alarm-clock-pro-for-windows
Download ResHackResHack ( Resource Hacker) is a freeware which allows to view, modify, rame, to delete or to extract resources in executable files (.exe, .ocx, .dll, .res, etc.). It has an internal compiler/decompiler which allows to : · Read cursors, icones,... en.kioskea.net/telecharger/telecharger-1536-reshack
Katherine Heigl top girlfriend pick for Askmen readersUS actress Katherine Heigl arriving at the premiere of "27 Dresses" in Westwood, California in January. Readers of popular men's lifestyle website AskMen.com voted Actress Katherine Heigl this year's most desirable woman to have as a... en.kioskea.net/actualites/katherine-heigl-top-girlfriend-pick-for-askmen-readers-10042-actualite.php3
Computer - Read-only memory (ROM) There is a type of memory that stores data without electrical current; it is the ROM (Read Only Memory) or is sometimes called non-volatile memory as it is not erased when the system is switched off. This type of memory lets you stored the data... en.kioskea.net/pc/rom.php3
PC Assembly - Getting the case ready When preparing to build a PC make sure to have the following: a phillips screwdriver, the necessary screws and the various cables and connectors. There are some simple guidelines that should be followed: Never screw things too tight!Never use force!... en.kioskea.net/assemblage/preparation-boitier.php3
Operating systems - Environment variables An environment variable is a dynamic value loaded into the memory that can be used by several processes operating simultaneously. On most operating systems, the location of some libraries or of the main system executables may be different depending... en.kioskea.net/systemes/variables-environnement.php3