This file is indexed.

/usr/lib/bash/hashstash.sh is in libbash 0.9.11-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#               Do not run this script directly!
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
###########################################################################
# Copyright (c) 2004-2009 Hai Zaar and Gil Ran                            #
#                                                                         #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of version 3 of the GNU General Public License as       #
# published by the Free Software Foundation.                              #
#                                                                         #
###########################################################################
#
# $Date: 2009-05-10 20:08:10 +0300 (Sun, 10 May 2009) $
# $Author: hai-zaar $
#
# Set of fuctions that implement hash data structure. 
# Each hash can have both keys and subhashes. 
# WARNING:
#	You can not have key and subhash with the same name. 
#	Its because, we do not have actual data types. I.e. you can call
#	hashGet on hash with its subhash as key - it will return list of subhash's keys.
#
# Hash Variables
#	The hash variable is transparent to the user of these functions. 
#	Such variables should be used only through the functions.
# 	Each "hash variable" holds a list of keys.
# 	For example: The variable for the hash DIR that holds the `keys' `etc' `bin' `lib'
#	will be: _HASH_DIRS_=" etc bin lib "
# 	Notice that before and _after_  every key there must be a white space (can be more then one).
#
# Key Variables
# 	The key value is held in a variable that is named ${HashName}${Key}_. 
#	Note trailing `_') in ${HashName}.
# 	For example: The value of the key `etc' of the hash DIR will be in the variable _HASH_DIRS_etc_.
# 	Notice that this name can also be the name of a hash named DIRS_etc.
#	The key variable is also transparent to the user of these functions. 
#	These variables should be used only through the functions.
#
# Sub-Hashes
#	A sub-hash is a hash key that holds a keys list.
# 	This way, if you set a hash key value to be a list in the suitable form, 
#	it can be used as a "sub hash".
# 	Use of hashSet ensures that the list will be in the right form.

#-------------------------------------------------------------------------
#EXPORT=hashGet hashSet hashKeys hashDelete hashRemove
#REQUIRE=
#-------------------------------------------------------------------------

# The prefix of the hashes variables. 
# NOTE: Do not name any of your variables _HASH_*
PREFIX="__hash_"

#
# DEBUG=1 - If DEBUG will not be commented, debug printouts will be enabled
#DEBUG=1

###################
#### FUNCTIONS ####
###################

#
# hashSet <Value> <Key> <HashName> [SubHashName [...] ]
#
#	Adds a value to the hash. Value will be the value of the key Key in the hash HashName.
#	For example if you have (or want to define) hash C, which is subhash of hash B, 
#	which is subhash of hash A and C has key ckey1 with value cval1, then you should run:
#		hashSet cval1 ckey1 A B C 
#	
#	Parameters:
#		Value		- The value to set in HashName[Key].
#		Key			- The key for the value Value.
#		HashName 
#		[SubHashName [...] ]
#			A string that contains the name of the hash. 
#			If the hash is a sub hash of another hash, the "father hash" 
#			name MUST BE WRITTEN FIRST, followed by the sub-hash name.
hashSet()
{
	local Value=$1
	local Key=$2
	shift 2
	
	# Parse the key variable name ${PREFIX}_${HashName}_${SubHashName}_..._${Key}_
	# Example: For the parameters "VALUE1 KEY1 DIRS ETC ", the variable name will be _HASH_DIRS_ETC_KEY1_
	local ParamsString="$*"
	local HashName=${PREFIX}${ParamsString// /_}_
	local KeyVarName=${HashName}${Key}_

	# Set the value in the key variable
	test $DEBUG && echo eval "$KeyVarName"'="'$Value'"' 1>&2
	eval "$KeyVarName"'="'$Value'"'

	# Check if the key is not in the keys list
	hashKeys $*
	test $DEBUG && echo retval=$retval 1>&2
	if ! [[ $retval = *" $Key "*  ]] ; then
		# Add the key to the keys list
		test $DEBUG && echo eval $HashName'="${'$HashName'}'" $Key "'"' 1>&2
		eval $HashName'=${'$HashName'}"'" $Key "'"'
	fi
}

#
# $retval hashGet <Key> <HashName> [SubHashName [...] ]
#	Returns the value of Key in HashName in the variable $retval.
#	
#	Parameters:
#		HashName 
#		[SubHashName [...] ]
#			A string that contains the name of the hash.
#			If the hash is a sub hash of another hash, the "father hash" 
#			name MUST BE WRITTEN FIRST, followed by the sub-hash name.
#			See hashSet for example.
#	Key
#		The hash key of the value \c Value.
#
#	Return value:
#		The value of the key Key in the hash HashName.
#		The value is returned in the variable $retval.
hashGet()
{
	local Key=$1
	shift
	
	# Parse the key variable name ${PREFIX}_${HashName}_${SubHashName}_..._${Key}_
	# Example: For the parameters "KEY1 DIRS ETC", the variable name will be _HASH_DIRS_ETC_KEY1_
	local ParamsString="$*"
	local HashName=${PREFIX}${ParamsString// /_}_
	local KeyVarName=${HashName}${Key}_
	
	# Put the value of the key in $retval
	test $DEBUG && echo eval 'retval=${'$KeyVarName'}' 1>&2
	eval 'retval=${'$KeyVarName'}'
}

#
# $retval hashKeys <HashName> [SubHashName [...] ]
#
#	Returns a list of keys of the hash HashName in the variable $retval.
#
#	Parametes:
#		HashName
#		[SubHashName [...] ]
#			A string that contains the name of the hash. 
#			If the hash is a sub hash of another hash, the "father hash" 
#			name MUST BE WRITTEN FIRST, followed by the sub-hash name.
#			See hashSet for example.
#
#	Return value:
#		A list of the keys of the hash HashName.
#		The list is returned in the variable $retval.
hashKeys()
{
	# Parse the hash name ${PREFIX}${HashName}_${SubHashName}_...
	# Example: For the parameters "DIRS ETC" the hash name will be _HASH_DIRS_ETC_
	local ParamsString="$*"
	local HashName=${PREFIX}${ParamsString// /_}_
	
	test $DEBUG && echo eval 'retval=${'$HashName'}' 1>&2
	eval 'retval=${'$HashName'}'
}

#
# hashRemove <Key> <HashName> [SubHashName [...] ]
#
#	Removes the key Key from the hash HashName
#	
#	Parameters:
#		HashName
#		[SubHashName [...] ]
#			A string that contains the name of the hash.
#			If the hash is a sub hash of another hash, the "father hash" 
#			name MUST BE WRITTEN FIRST, followed by the sub-hash name.
#			See hashSet for example.
#		Key
#			The hash key that gets the value Value.
hashRemove()
{
	local Key=$1
	shift
	
	# Parse the hash name ${PREFIX}${HashName}_${SubHashName}_...
	# Example: For the parameters "DIRS ETC" the hash name will be _HASH_DIRS_ETC_
	local ParamsString="$*"
	local HashName=${PREFIX}${ParamsString// /_}_
	local KeyVarName=${HashName}${Key}_

	# unset the key variable
	eval "unset ${KeyVarName}"

	# Remove the key from the hash	
	eval $HashName'=${'$HashName'//' $Key '/}'
}

#
# hashDelete <HashName> [SubHashName [...] ]
#
#	Deletes the hash HashName [ SubHashName [...]]
#	
#	Parameters:
#		HashName
#		[SubHashName [...] ]
#			A string that contains the name of the hash.
#			If the hash is a sub hash of another hash, the "father hash"
#			name MUST BE WRITTEN FIRST, followed by the sub-hash name.
#			See "hashSet" for example.
hashDelete()
{
	# Parse the hash name ${PREFIX}${HashName}_${SubHashName}_...
	# Example: For the parameters "DIRS ETC" the hash name will be _HASH_DIRS_ETC_
	local ParamsString="$*"
	local HashName=${PREFIX}${ParamsString// /_}_

	# unset the hash variable
	unset `eval '${'$HashName'}'`
}